2017-09-14 18 views
0

サードパーティからSOAP Webサービスを使用しようとしています。私はmavenプロジェクトを持っており、提供されたWSDL上でwsdl2javaを使用してコード生成を実行するためにcxf-codegen-pluginを使用しようとしています。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 

をIました要素を指すようにノードのパスを変更し、完全なノードのパス構造も使用しました。 node = "wsdl:definitions/wsdl:types ...."しかし、私は同じエラーが発生し続ける。私はここでサークルで回っているように感じる。

誰かが私が間違っている場所を見て、それを私に指摘することができたら、これは初めてのことです。

ありがとうございます。

答えて

0

私はこれを最後に考え出しました。 jaxb:bindingsがノードのパスを解決できないことが判明しました。そこでjaxwsを使用してパスを解決し、jaxbを使用してプロパティ名を更新しました。

作業するバインディング・ファイルは、次のようになります。

<jaxws:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:s="http://www.w3.org/2001/XMLSchema" version="2.1"> 
 
    <jaxws:bindings node=".//s:element[@name='SomeId']"> 
 
    <jaxb:property name="anotherId" /> 
 
    </jaxws:bindings> 
 
</jaxws:bindings>

関連する問題