XFire 如何修改WSDL 参数名

WebServices接口的描述文件WSDL中经常出现类似 name="in0" 的参数配置,如下:


<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in2" nillable="true" type="xsd:string" />

这样对于客户端来说太不方便了,可读性很差,只能对着接口文档才知道每个参数的名字。那么,如何让这些不友好的名称改成友好的参数名呢?如:name="callTime"。实现步骤如下:

[b]第一步[/b]、JSR181注解配置(也称:annotation方式),对webservice接口类进行注解:


package com.metarnet.webservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

@WebService
public interface IAlarmSwitchService {

@WebMethod
@WebResult(name="resultMsg")
public String transferAlarm(@WebParam(name="serSupplier")String serSupplier,
@WebParam(name="serCaller")String serCaller,
@WebParam(name="callerPwd")String callerPwd,
@WebParam(name="callTime")String callTime,
@WebParam(name="opDetail")String opDetail);

}

[b]第二步[/b]、services.xml文件配置

<?xml version="1.0" encoding="UTF-8"?>
<beans>
<service xmlns="http://xfire.codehaus.org/config/1.0">
<name>AlarmSwitchService</name>
<serviceClass>
com.metarnet.webservice.IAlarmSwitchService
</serviceClass>
<implementationClass>
com.metarnet.webservice.AlarmSwitchServiceImpl
</implementationClass>
<serviceFactory>jsr181</serviceFactory><!--这个必须配置,否则还是显示in0...-->
</service>
</beans>

[b]第三步[/b]、至此,配置步骤已完成,查看效果:

<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="serSupplier" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="serCaller" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="callerPwd" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="callTime" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="opDetail" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值