当WSDL存储在一个文件中时,Jax-WS和Jaxb可以正常工作并执行“定制模式”绑定。
但是,当主wsdl包含带有<xs:import>
标签的从属wsdl时,JAXB绑定不起作用。
目标是将软件包名称从org.wrong更改为org.right
请参阅下面的WSDL和映射文件。 “真实的” wsdl繁琐得多,我只是试图尽可能简化结构
Master.wsdl
<wsdl:definitions name="CurrentTimeService"
targetNamespace="http://org" xmlns:tns="http://org"
xmlns:wrong="http://wrong.org"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://wrong.org" schemaLocation="slave.wsdl"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="forestMsg">
<wsdl:part element="wrong:Forest" name="Forest" />
</wsdl:message>
</wsdl:definitions>
slave.wsdl
<xs:schema targetNamespace="http://wrong.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" xmlns="http://wrong.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xs:element name="Forest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="99" minOccurs="0" name="Apple">
<xs:complexType>
<xs:sequence>
<xs:element name="Size" type="xsd:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
绑定文件master.xjb:
<jaxws:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:import[@namespace='http://wrong.org']">
<jaxb:schemaBindings>
<jaxb:package name="org.right" />
</jaxb:schemaBindings>
</jaxws:bindings>
</jaxws:bindings>
绑定文件slave.xjb:
<jaxws:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
wsdlLocation="../wsdl/slave.wsdl">
<jaxws:bindings node="xs:schema[@targetNamespace='http://wrong.org']">
<jaxb:schemaBindings map="true">
<jaxb:package name="org.right" />
</jaxb:schemaBindings>
</jaxws:bindings>
</jaxws:bindings>
绑定被忽略。但是,如果我将slave.wsdl
的内容而不是标签<xs:import>
放到master中,然后稍微更改绑定文件(删除slave.xjb
并更新master.xjb
中的xpath-一切正常。要用jaxws交换jaxb,反之亦然,使用xpath,只保留一个绑定文件-没有任何帮助。
Xpath是正确的,如果我将XPATH更改为错误的XPATH,则CXF会生成错误消息
任何想法都可以做什么?