【发布时间】:2012-06-16 08:07:44
【问题描述】:
我正在使用 JAX-WS 开发 WebService(我在 jaxws-maven-plugin 上使用 wsimport 目标)。我编写了一个导入 XSD 模式的 WSDL。
WEB-INF/wsdl/service.wsdl
WEB-INF/wsdl/service.xsd
我还生成了 Web 服务类并创建了端点等。到目前为止一切都很好。当我在 Tomcat 7 上运行我的服务时,一切正常。我可以通过以下方式在浏览器中访问 wsdl:
http://localhost:8080/webService/servlet-url?wsdl
但我无法访问 xsd 架构。问题出在这个 wsdl 中:
<xsd:schema>
<xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="service.xsd"/>
</xsd:schema>
当然,在生成类 wsdl 和 xsd 的过程中,它们位于本地路径上,但我希望在 Web 服务运行时可以远程访问它们。我知道 schemaLocation 应该是这样的“http://localhost:8080/webService/servlet-url?xsd=1”。
在浏览器导入的 wsdl 中应该是这样的:
<xsd:schema>
<xsd:import namespace="http://ws.service/domain/1.0" schemaLocation="http://localhost:8080/webService/servlet-url?wsdl&resource=service.xsd"/>
</xsd:schema>
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>
等等……
【问题讨论】: