[英]JAX-WS: multiple “xsd:schema” under “wsdl:types”, why?
我正在尝试用分离的Ednpoint-s编写测试Web服务应用程序,如下所示:
package test;
import ...
public class Main {
HttpsServer server;
HashMap<String, Endpoint> endpointMap;
public Main() {
try {
SSLContext ssl = ...
this.server = HttpsServer.create(
new InetSocketAddress("localhost", 8089),
8089);
this.endpointMap = new HashMap();
endpointMap.put("/test11", Endpoint.create(new SOAPService1()));
endpointMap.put("/test22", Endpoint.create(new SOAPService2()));
} catch (Exception e) {
e.printStackTrace();
}
}
public void start() {
server.start();
for (String uri : endpointMap.keySet()) {
endpointMap.get(uri).publish(
server.createContext(uri));
}
}
public static void main(String[] args) throws Exception {
new Main().start();
}
}
结果,我在以下位置获得了wsdl
https://localhost:8089/test11?wsdl
在类型下具有多个xsd:schema :
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test1.service.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://test1.service.com" name="TEST1Service">
<types>
<xsd:schema>
<xsd:import namespace="http://test2.service.com" schemaLocation="https://localhost:8089/test11?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://test1.service.com" schemaLocation="https://localhost:8089/test11?xsd=2"/>
</xsd:schema>
</types>
<message name="test">
<part name="parameters" element="tns:test"/>
</message>
<message name="testResponse">
<part name="parameters" element="tns:testResponse"/>
</message>
<portType name="SOAPService1">
<operation name="test">
<input wsam:Action="http://test1.service.com/SOAPService1/testRequest" message="tns:test"/>
<output wsam:Action="http://test1.service.com/SOAPService1/testResponse" message="tns:testResponse"/>
</operation>
</portType>
<binding name="TEST1PortBinding" type="tns:SOAPService1">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="test">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="TEST1Service">
<port name="TEST1Port" binding="tns:TEST1PortBinding">
<soap:address location="https://localhost:8089/test11"/>
</port>
</service>
</definitions>
WSDL可在第二个URL获得
https://localhost:8089/test22?wsdl
才不是:
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test2.service.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://test2.service.com" name="TEST2Service">
<types>
<xsd:schema>
<xsd:import namespace="http://test2.service.com" schemaLocation="https://localhost:8089/test22?xsd=1"/>
</xsd:schema>
</types>
<message name="test">
<part name="parameters" element="tns:test"/>
</message>
<message name="testResponse">
<part name="parameters" element="tns:testResponse"/>
</message>
<portType name="SOAPServiceInterface2">
<operation name="test">
<input wsam:Action="http://test2.service.com/SOAPServiceInterface2/testRequest" message="tns:test"/>
<output wsam:Action="http://test2.service.com/SOAPServiceInterface2/testResponse" message="tns:testResponse"/>
</operation>
</portType>
<binding name="TEST2PortBinding" type="tns:SOAPServiceInterface2">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="test">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="TEST2Service">
<port name="TEST2Port" binding="tns:TEST2PortBinding">
<soap:address location="https://localhost:8089/test22"/>
</port>
</service>
</definitions>
我希望它们完全分开而不彼此了解,但是正如您所看到的,第一个甚至包括第二个的架构。 我做错了什么?
我会回答我自己的问题。 通过注释服务类
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
它删除了多余的XSD并解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.