这几天被这个东西折腾死了,原本以为只要修改DTO中的字段名称为大写即可,但是却老是不行,发布的WSDL报文还是小写开头的,蛋疼ing。
现在讲解决方案,标注下,方便以后查找:
平时的WSDL文件是这样的:
<complexType name="Request">
<sequence>
<element name="requestId" nillable="true" type="xsd:string"/>
<element name="requestTime" nillable="true" type="xsd:string"/>
<element name="destinationId" nillable="true" type="xsd:string"/>
<element name="destinationAttr" type="xsd:int"/>
<element name="destinationAttrDetail" nillable="true" type="xsd:int"/>
<element name="balanceType" type="xsd:int"/>
<element name="rechargeUnit" type="xsd:int"/>
<element name="objType" nillable="true" type="xsd:string"/>
<element name="bonus" nillable="true" type="impl:ArrayOf_tns1_Bonus"/>
<element name="rechargeAmount" type="xsd:int"/>
<element name="prolongDays" type="xsd:int"/>
<element name="requestAmount" type="xsd:int"/>
<element name="rechargeFlag" nillable="true" type="xsd:int"/>
<element name="rechargeFlowAmount" nillable="true" type="xsd:int"/>
<element name="destinationExpTime" nillable="true" type="xsd:int"/>
</sequence>
</complexType>
想要达到以下的效果,提供给对端访问:
<complexType name="Request">
<sequence>
<element name="requestId" nillable="true" type="xsd:string"/>
<element name="requestTime" nillable="true" type="xsd:string"/>
<element name="destinationId" nillable="true" type="xsd:string"/>
<element name="destinationAttr" type="xsd:int"/>
<element name="destinationAttrDetail" nillable="true" type="xsd:int"/>
<element name="balanceType" type="xsd:int"/>
<element name="rechargeUnit" type="xsd:int"/>
<element name="objType" nillable="true" type="xsd:string"/>
<element name="bonus" nillable="true" type="impl:ArrayOf_tns1_Bonus"/>
<element name="rechargeAmount" type="xsd:int"/>
<element name="prolongDays" type="xsd:int"/>
<element name="requestAmount" type="xsd:int"/>
<element name="RechargeFlag" nillable="true" type="xsd:int"/>
<element name="RechargeFlowAmount" nillable="true" type="xsd:int"/>
<element name="DestinationExpTime" nillable="true" type="xsd:int"/>
</sequence>
</complexType>
1.和对方要一个WSDL文件
方法为
public Response hello(Request requDto) ...
入参为:
<complexType name="Request">
<sequence>
<element name="requestId" nillable="true" type="xsd:string"/>
<element name="requestTime" nillable="true" type="xsd:string"/>
<element name="destinationId" nillable="true" type="xsd:string"/>
<element name="destinationAttr" type="xsd:int"/>
<element name="destinationAttrDetail" nillable="true" type="xsd:int"/>
<element name="balanceType" type="xsd:int"/>
<element name="rechargeUnit" type="xsd:int"/>
<element name="objType" nillable="true" type="xsd:string"/>
<element name="bonus" nillable="true" type="impl:ArrayOf_tns1_Bonus"/>
<element name="rechargeAmount" type="xsd:int"/>
<element name="prolongDays" type="xsd:int"/>
<element name="requestAmount" type="xsd:int"/>
<element name="RechargeFlag" nillable="true" type="xsd:int"/>
<element name="RechargeFlowAmount" nillable="true" type="xsd:int"/>
<element name="DestinationExpTime" nillable="true" type="xsd:int"/>
</sequence>
</complexType>
2.用Eclipse工具可以很方便的建服务端和客户端的JAVA类
这里我们通过WSDL生成对应的接口DTO类:
右键单击WSDL文件,并选择新建Web Service
就可以生成对应的服务类
此时只要注意自动生成的代码里,有个静态代码块里对应的名称要为大写开头即可