我的aa.xsd如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://wwwtest.com/test" xmlns:abc="http://wwwtest.com/test">
<xs:simpleType name="APP_TYPE">
<xs:restriction base="xs:string">
<xs:enumeration value="ABC" />
<xs:enumeration value="DEF" />
</xs:restriction>
</xs:simpleType>
<xs:element name="RootElement" type="abc:RootElementType" />
<xs:complexType name="RootElementType">
<xs:choice>
<xs:sequence>
<xs:element ref="abc:UserRequest" />
<xs:any minOccurs="0" />
</xs:sequence>
<xs:sequence>
<xs:element ref="abc:UserResponse" />
<xs:any minOccurs="0" />
</xs:sequence>
</xs:choice>
</xs:complexType>
<xs:element name="UserRequest" type="abc:UserRequestType" />
<xs:complexType name="UserRequestType">
<xs:sequence>
<xs:element name="UserLoginName" type="xs:string" />
<xs:element ref="abc:VendorApp" />
</xs:sequence>
</xs:complexType>
<xs:element name="VendorApp" type="abc:VendorAppType" />
<xs:complexType name="VendorAppType">
<xs:sequence>
<xs:element name="AppName" type="abc:APP_TYPE" />
</xs:sequence>
</xs:complexType>
<xs:element name="UserResponse" type="abc:UserResponseType" />
<xs:complexType name="UserResponseType">
<xs:sequence>
<xs:element name="SessionKey" type="xs:string" />
<xs:element name="SessionKeyExpDate" type="xs:date" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
如下所示编写WSDL。
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="ABCcomacc" targetNamespace="http://wwwtest.com/test/com/acc/" xmlns:abc="http://wwwtest.com/test" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ws="http://wwwtest.com/test/com/acc/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://wwwtest.com/test" schemaLocation="aaa.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="xyzSearchRequest">
<wsdl:part element="abc:RootElement" name="parameters"/>
</wsdl:message>
<wsdl:message name="xyzSearchResponse">
<wsdl:part element="abc:RootElement" name="parameters"/>
</wsdl:message>
<wsdl:portType name="ABCcomacc">
<wsdl:operation name="xyzSearch">
<wsdl:input message="ws:xyzSearchRequest"/>
<wsdl:output message="ws:xyzSearchResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ABCcomaccSOAP12" type="ws:ABCcomacc">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="xyzSearch">
<soap12:operation soapAction="http://wwwtest.com/test/com/acc/xyzSearch"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ABCcomacc">
<wsdl:port binding="ws:ABCcomaccSOAP12" name="ABCcomaccSOAP12">
<soap12:address location="http://localhost:9080/ABCcomacc/ABCcomacc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我的骨架类实现如下所示。
@javax.jws.WebService (endpointInterface="com.wwwtest.test.com.acc.ABCcomacc", targetNamespace="http://wwwtest.com/test/com/acc/", serviceName="ABCcomacc", portName="ABCcomaccSOAP12", wsdlLocation="WEB-INF/wsdl/LTCCommonAccord.wsdl")
@javax.xml.ws.BindingType (value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
public class ABCcomaccSOAP12Impl{
public void xyzSearch(Holder<RootElementType> parameters) {
// TODO Auto-generated method stub
return;
}
}
此方法的返回类型为void
,方法参数为Holder<RootElementType> parameters
,但返回类型和方法参数应为RootElementType。
任何人都可以知道为什么我得到这个输出。请指教我...... 我正在使用JAX-WS。
答案 0 :(得分:1)
请求和响应元素的名称如下所示。
<wsdl:message name="xyzSearchRequest">
<wsdl:part element="abc:RootElement" name="reqparams"/>
</wsdl:message>
<wsdl:message name="xyzSearchResponse">
<wsdl:part element="abc:RootElement" name="respparams"/>
</wsdl:message>
你是如何生成绑定的?如果你从maven使用wsimport目标,那么写一个绑定文件并在绑定部分下面添加
<enableWrapperStyle>false</enableWrapperStyle>