我正在尝试使用 WSDL 并使用 maven-jaxb2-plugin 生成绑定类。
WSDL 是这样的,
<wsdl:definitions>
<wsdl:types>
...
</wsdl:types>
...
<wsdl:message name="IServiceWeb_GetPaymentInfo_InputMessage">
<wsdl:part name="parameters" element="tns:GetPaymentInfo"/>
</wsdl:message>
...
<wsdl:portType name="IServiceWeb">
...
<wsdl:operation name="GetPaymentInfo">
<wsdl:input wsaw:Action="*****" message="tns:IServiceWeb_GetPaymentInfo_InputMessage"/>
<wsdl:output wsaw:Action="*****" message="tns:IServiceWeb_GetPaymentInfo_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
当我最初尝试生成类时,我收到了这个错误,
org.xml.sax.SAXParseException: A class/interface with the same name "org.package.GetPaymentInfoResponse" is already in use. Use a class customization to resolve this conflict.
我添加了一个包含此内容的 binding.xjb 文件,
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" version="2.1">
<bindings
node="wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_OutputMessage']/wsdl:part[@name='parameters']">
<class name="GetPaymentInfoOutputMessage" />
</bindings>
</bindings>
我得到的错误是,
com.sun.istack.SAXParseException2: XPath evaluation of "wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_OutputMessage']/wsdl:part[@name='parameters']" results in empty target node
有什么建议可以生成这些文件吗?
编辑 我声明了错误的节点,IServiceWeb_GetPaymentInfo_InputMessage 应该是 IServiceWeb_GetPaymentInfo_InputMessage,更正的绑定是,
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" version="2.1">
<bindings
node="wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_InputMessage']/wsdl:part[@name='parameters']">
<class name="GetPaymentInfoOutputMessage" />
</bindings>
</bindings>
错误信息是,
com.sun.istack.SAXParseException2: XPath evaluation of "wsdl:definitions/wsdl:message[@name='IServiceWeb_GetPaymentInfo_InputMessage']/wsdl:part[@name='parameters']" results in empty target node