zoukankan      html  css  js  c++  java
  • 在XFire中使用友好的接口参数名

    http://www.blogjava.net/sxyx2008/archive/2010/06/07/322945.html

    近期在做多个数据库应用交互系统,其中数据交互采用了webservice的方式,说到webservice项目中不得不用到xfire这个框架,有了它我们几乎不用写代码,就可以很快速的创建自己的webservice
            但在使用的过程中遇到一些小细节上的问题:
    就是在写webservice接口的时候,通常大家都会定义一些方法的参数,但是根据xfire的xsd文件描述情况来看,它的参数命名通常是in0,in1等等,一次类推,很不友好。
            按照XFire-Spring生成的WSDL文档中接口参数名极不友好:
    <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" />
    <xsd:element maxOccurs="1" minOccurs="1" name="in3" nillable="true" type="xsd:string" />
            大家都知道,作为一个合格的程序员,在写代码的时候方法参数命名什么的要尽量做到见名知意,显然他这种风格是不适合我们的。因此我们要创新,这就有了下文。
            如何自动将in0与in1替换成友好的参数名称呢 ?
            方法如下:
      1.在与接口类同一包下面建一个接口类名称.aegis.xml 的文件,内容如下
    <?xml version="1.0" encoding="UTF-8"?>  
    <mappings>  
        <mapping>  
           <method name="settleMessage">  
               <parameter index="0"  mappedName="id" />
               <parameter index="1"  mappedName="username" />
               <parameter index="2"  mappedName="pass" /> 
           </method>
       </mapping>  
    </mappings> 

            注意:
                    name为接口中方法名称
                    index为方法中第一个参数
                    mappedName为替换后的名称
                    该XML文件的位置一定要与你定义的webservice的接口位于同一个目录(包下)否则不起作用

  • 相关阅读:
    Blank page instead of the SharePoint Central Administration site
    BizTalk 2010 BAM Configure
    Use ODBA with Visio 2007
    Handling SOAP Exceptions in BizTalk Orchestrations
    BizTalk与WebMethods之间的EDI交换
    Append messages in BizTalk
    FTP protocol commands
    Using Dynamic Maps in BizTalk(From CodeProject)
    Synchronous To Asynchronous Flows Without An Orchestration的简单实现
    WSE3 and "Action for ultimate recipient is required but not present in the message."
  • 原文地址:https://www.cnblogs.com/IamThat/p/3065129.html
Copyright © 2011-2022 走看看