我試圖從第三方使用SOAP Web服務。我有一個maven項目,我正試圖使用cxf-codegen-plugin在提供的WSDL上使用wsdl2java運行代碼生成。CXF:wsdl2java錯誤 - WSDL包含重複名稱
WSDL的問題是在同一個複雜類型中有一個元素和一個具有相同名稱的屬性。所以,我得到以下錯誤試圖運行mvn乾淨安裝時:
Property "SomeId" is already defined. Use <jaxb:property> to resolve this conflict.
環視方法後解決這似乎是添加綁定文件重命名竟然放棄錯誤的屬性名稱。
我綁定文件看起來是這樣的:
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jxb:bindings node=".//s:attribute[@name='SomeId']">
<jxb:property name="anotherId" />
</jxb:bindings>
</jxb:bindings>
WSDL片段:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns=「namespace」 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace=「namespace」>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace=「namespace」>
<s:element name="GetData">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="request">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Nbr" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetDataResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDataResult">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ITEM">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Pty">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name=「SomeId」 type="s:string"/>
</s:sequence>
<s:attribute name="SomeId" type="s:string" />
</s:complexType>
(注: '命名空間' 隱藏公司名稱)
而且我已將POM指向綁定文件:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/META-INF/wsdl/a.wsdl</wsdl>
<wsdlLocation>classpath:META-INF/wsdl/a.wsdl</wsdlLocation>
<packagenames>
REMOVED
</packagenames>
<extraargs>
<extraarg>-fe</extraarg>
<extraarg>jaxws21</extraarg>
<extraarg>-autoNameResolution</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
</extraargs>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/META-INF/wsdl/binding.xsd</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
問題:
當我運行 '命令mvn全新安裝' 與此設置中,我得到以下錯誤:
XPath evaluation of ".//s:attribute[@name='SomeId']" results in empty target node
我已經將節點路徑改爲指向元素,並且還使用了完整的節點路徑結構,例如節點=「wsdl:定義/ wsdl:類型....」但我不斷收到相同的錯誤。感覺就像我在這裏的圈子裏一樣。
如果有人能夠看到我要出錯的地方並向我指出這一點,我將不勝感激,因爲這是我第一次嘗試實施這樣的事情。
在此先感謝。