我正在使用JAX-WS开发WebService(我在jaxws-maven-plugin上使用wsimport目标).我编写了一个导入XSD架构的WSDL.
WEB-INF/wsdl/service.wsdl
WEB-INF/wsdl/service.xsd
Run Code Online (Sandbox Code Playgroud)
我还生成了Web服务类并创建了端点和所有.到目前为止,一切都很顺利.当我在Tomcat 7上运行我的服务时一切正常.我可以从我的浏览器访问wsdl:
http://localhost:8080/webService/servlet-url?wsdl
Run Code Online (Sandbox Code Playgroud)
但我无法访问xsd架构.问题出在这个wsdl中:
<xsd:schema>
<xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="service.xsd"/>
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)
当然,在生成类时,wsdl和xsd位于本地路径上,但我希望在Web服务运行时可以远程访问它们.我知道schemaLocation应该是这样的"http:// localhost:8080/webService/servlet-url?xsd = 1".
在wsdl中显示的浏览器导入schould看起来像:
<xsd:schema>
<xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="http://localhost:8080/webService/servlet-url?wsdl&resource=service.xsd"/>
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)
localhost:8080/webService/servlet?wsdl给了我:
wsdl:definitions targetNamespace="http://ws.serv.com/Service/1.0" name="emuiaService">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://ws.serv.com/Service/domain/1.0" schemaLocation="schema.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="halloMsg">
<wsdl:part name="parameters" element="dom:halloRequest"/>
</wsdl:message>
<wsdl:message name="halloResponseMsg">
<wsdl:part name="return" element="dom:halloResponse"/>
</wsdl:message>
Run Code Online (Sandbox Code Playgroud)
等等...