Chinaunix首页 | 论坛 | 博客
  • 博客访问: 530175
  • 博文数量: 135
  • 博客积分: 3568
  • 博客等级: 中校
  • 技术积分: 1942
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-19 17:52
文章分类

全部博文(135)

文章存档

2012年(29)

2011年(41)

2010年(26)

2009年(12)

2008年(9)

2007年(12)

2006年(6)

分类: Java

2011-06-02 13:46:18

生成服务器端代码的命令:
wsdl2java -o generated-adb-server -f -ss -sd -ap  -uri services.wsdl

生成客户端代码的命令:
wsdl2java -o generated-adb-client -f -sd -uri services.wsdl


注意:
1. 使用默认的ADB方式进行数据绑定的时候,如果同一个Package下使用了多个WSDL,
需要注意将不同版本的ExtensionMapper进行合并。

2. SystemException 需要手动使其继承 RuntimeException

3. 生成的 services.xml 需要在其基础上修改,并加入对Spring的支持。





在使用时,需要自己修改其中的package了~,替换 ${服务名称},${业务ID}等变量。
PS:是用Eclipse的图形化界面编辑很Easy滴。

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <wsdl:definitions
  3.   name="${服务名称}"
  4.   targetNamespace="{业务ID}.test.me/"
  5.   xmlns:tns="{业务ID}.test.me/"
  6.   xmlns:tnsb="{业务ID}.test.me/"
  7.   xmlns:tnsc=""
  8.   xmlns:wsdl=""
  9.   xmlns:xsd=""
  10.   xmlns:http="http/"
  11.   xmlns:soap="soap/"
  12.   xmlns:soap12="soap12/"
  13.   xmlns:mime="mime/">

  14.   <wsdl:documentation> xxxxxxxxxxxxxxxxxxxxxxxx </wsdl:documentation>

  15.   <wsdl:types>
  16.   
  17.     <xsd:schema
  18.         attributeFormDefault="unqualified"
  19.         elementFormDefault="unqualified"
  20.         targetNamespace="{业务ID}.test.me/">

  21.       <xsd:element name="${服务名称}Input">
  22.         <xsd:complexType>
  23.           <xsd:sequence>
  24.             <xsd:element name="userId" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="false" >
  25.               <xsd:annotation>
  26.                 <xsd:documentation> 用户ID </xsd:documentation>
  27.               </xsd:annotation>
  28.             </xsd:element>
  29.             
  30.             <xsd:element name="password" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="false" >
  31.               <xsd:annotation>
  32.                 <xsd:documentation> 用户密码 </xsd:documentation>
  33.               </xsd:annotation>
  34.             </xsd:element>
  35.           </xsd:sequence>
  36.         </xsd:complexType>
  37.       </xsd:element>

  38.       <xsd:element name="${服务名称}Output">
  39.         <xsd:complexType>
  40.           <xsd:sequence>
  41.             <xsd:element name="success" type="xsd:boolean" minOccurs="0" maxOccurs="1" nillable="false" >
  42.               <xsd:annotation>
  43.                 <xsd:documentation> 是否认证成功 </xsd:documentation>
  44.               </xsd:annotation>
  45.             </xsd:element>
  46.           </xsd:sequence>
  47.         </xsd:complexType>
  48.       </xsd:element>
  49.     </xsd:schema>
  50.     
  51.     <xsd:schema
  52.         attributeFormDefault="unqualified"
  53.         elementFormDefault="unqualified"
  54.         targetNamespace="">
  55.       <xsd:element name="ServiceException">
  56.         <xsd:complexType>
  57.           <xsd:sequence>
  58.             <xsd:element name="errorCode" type="xsd:string" nillable="false" >
  59.               <xsd:annotation>
  60.                 <xsd:documentation> 错误代码 </xsd:documentation>
  61.               </xsd:annotation>
  62.             </xsd:element>
  63.             <xsd:element name="message" type="xsd:string" nillable="false">
  64.               <xsd:annotation>
  65.                 <xsd:documentation> 错误消息 </xsd:documentation>
  66.               </xsd:annotation>
  67.             </xsd:element>
  68.           </xsd:sequence>
  69.         </xsd:complexType>
  70.       </xsd:element>
  71.     </xsd:schema>

  72.   </wsdl:types>

  73.   <wsdl:message name="${服务名称}Request">
  74.     <wsdl:part name="input" element="tnsb:${服务名称}Input" />
  75.   </wsdl:message>

  76.   <wsdl:message name="${服务名称}Response">
  77.     <wsdl:part name="output" element="tnsb:${服务名称}Output" />
  78.   </wsdl:message>

  79.   <wsdl:message name="${服务名称}Fault">
  80.     <wsdl:part name="fault" element="tnsc:ServiceException" />
  81.   </wsdl:message>

  82.   <wsdl:portType name="${服务名称}PortType">
  83.     <wsdl:operation name="doService">
  84.       <wsdl:input name="input" message="tns:${服务名称}Request"/>
  85.       <wsdl:output name="output" message="tns:${服务名称}Response"/>
  86.       <wsdl:fault name="fault" message="tns:${服务名称}Fault" />
  87.     </wsdl:operation>
  88.   </wsdl:portType>

  89.   <wsdl:binding name="${服务名称}HttpBinding" type="tns:${服务名称}PortType">
  90.     <http:binding verb="POST" />
  91.     <wsdl:operation name="doService">
  92.       <http:operation location="${服务名称}/doService" />
  93.       <wsdl:input name="input">
  94.         <mime:content type="text/xml" part="doService" />
  95.       </wsdl:input>
  96.       <wsdl:output name="output">
  97.         <mime:content type="text/xml" part="doService" />
  98.       </wsdl:output>
  99.     </wsdl:operation>
  100.   </wsdl:binding>

  101.   <wsdl:binding name="${服务名称}Soap11Binding" type="tns:${服务名称}PortType">
  102.     <soap:binding transport="" style="document" />
  103.     <wsdl:operation name="doService">
  104.       <soap:operation soapAction="urn:doService" style="document" />
  105.       <wsdl:input name="input">
  106.         <soap:body use="literal" />
  107.       </wsdl:input>
  108.       <wsdl:output name="output">
  109.         <soap:body use="literal" />
  110.       </wsdl:output>
  111.       <wsdl:fault name="fault">
  112.         <soap:fault name="fault" use="literal" />
  113.       </wsdl:fault>
  114.     </wsdl:operation>
  115.   </wsdl:binding>

  116.   <wsdl:binding name="${服务名称}Soap12Binding" type="tns:${服务名称}PortType">
  117.     <soap12:binding transport=""
  118.       style="document" />
  119.     <wsdl:operation name="doService">
  120.       <soap12:operation soapAction="urn:doService" style="document" />
  121.       <wsdl:input name="input">
  122.         <soap12:body use="literal" />
  123.       </wsdl:input>
  124.       <wsdl:output name="output">
  125.         <soap12:body use="literal" />
  126.       </wsdl:output>
  127.       <wsdl:fault name="fault">
  128.         <soap12:fault name="fault" use="literal" />
  129.       </wsdl:fault>
  130.     </wsdl:operation>
  131.   </wsdl:binding>

  132.   <wsdl:service name="${服务名称}">
  133.     <wsdl:port name="${服务名称}HttpEndpoint" binding="tns:${服务名称}HttpBinding">
  134.       <http:address location="" />
  135.     </wsdl:port>

  136.     <wsdl:port name="${服务名称}HttpSoap11Endpoint" binding="tns:${服务名称}Soap11Binding">
  137.       <soap:address location="" />
  138.     </wsdl:port>

  139.     <wsdl:port name="${服务名称}HttpSoap12Endpoint" binding="tns:${服务名称}Soap12Binding">
  140.       <soap12:address location="" />
  141.     </wsdl:port>
  142.   </wsdl:service>

  143. </wsdl:definitions>



阅读(1631) | 评论(5) | 转发(0) |
给主人留下些什么吧!~~

jiangzhengqiu2012-05-09 11:14:49

AyinAy7: 恩  记下先.....
搭环境时只需要编写对应WSDL和描述文件service.xml,然后生成客户端和服务端代码就基本可调用了吧?

AyinAy72012-04-21 17:35:24

btpka3: 小2么,ChiDuZiHou?
有用没用,记下先~.....
恩  记下先

btpka32012-03-07 09:20:33

AyinAy7: 不过  貌似现在没用哦.....
小2么,ChiDuZiHou?
有用没用,记下先~

AyinAy72012-03-06 22:22:48

不过  貌似现在没用哦

AyinAy72012-03-06 22:18:25

我就知道 在你这里会有这个.....    太好了