`
learnmore
  • 浏览: 588620 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

xfire中wsdl中参数的友好化

 
阅读更多
需求:

    使用xfire开发webservice过程中出现生成的wsdl中的参数名称为in0,in1等不友好的参数名称,要求参数有一定的含义

解决办法:

    1.XML配置文件

      在接口类同一包下面建一个 接口类名称.aegis.xml 的文件,内容如下
  <?xml version="1.0" encoding="UTF-8"?> 
<mappings> 
    <mapping> 
       <method name="receive"> 
           <parameter index="0" mappedName="destnum" />
           <parameter index="1" mappedName="srcnum" />
           <parameter index="2" mappedName="msg" />

           <parameter index="3" mappedName="msgtype" />
       </method>
   </mapping> 
</mappings>

name为接口中方法名称
index为方法中第一个参数
mappedName为替换后的名称

2.JSR181注解配置(也称:annotation方式)

      @WebService
     public interface SMSstaterepReceive {
 
      @WebMethod
    @WebResult(name="result") //返回值的name
    public String receive(@WebParam(name="destnum")String destnum,@WebParam(name="srcnum")String srcnum,@WebParam(name="msg")String msg,@WebParam(name="msgtype")int msgtype);//接收接口;@WebParam 参数name
}

       services.xml配置文件配置接口

      <service>
    <!-- 接收上家短信平台的状态报告、上行信息接口 -->
    <name>SMSreceiveService</name>
    <namespace>http://scommnet.com/service/SMSreceiveService</namespace>
    <serviceClass>com.scommnet.sms.extend.scommnet.webservices.service.SMSstaterepReceive</serviceClass>
    <implementationClass>com.scommnet.sms.extend.scommnet.webservices.service.impl.SMSstaterepReceiveImpl</implementationClass>
    <serviceFactory>jsr181</serviceFactory> <!--这个必须配置,要不还是显示in0-->


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics