2014-09-05 2 views
4

우리는 제 3 자 WSDL로부터 wsdl2java로 Java를 생성하고 있습니다. WSDL은 포함이 xsdschema에서JAXB WSDL 외부의 XSD 바인딩

<wsdl:import namespace="http://somenamespace" location="xsdschema.xsd" /> 

는 = nillable로 "true"로 발전기는 ObjectFactory를에 충돌 (중복) 보고서 요소입니다. 바인딩 generateElementProperty = "false"를 사용하려고합니다. 그러나 WSDL에 대해 정의 된 바인딩 정의에서 생성기는이를 무시하고 xsd WSDL2Java에 대한 바인딩을 정의 할 때 XSD는 컴파일의 일부가 아니라고 말했습니다. 그것을 해결하는 방법? WSDL에 대한

XJB (generateElementProperty는 무시됩니다 - ObjectFactory를 여전히 중복 오류) : XSD에 대한

<jaxws:bindings version="2.0" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
       wsdlLocation="wsdl3rd.wsdl"> 

    <jaxb:bindings> 
     <jaxb:globalBindings generateElementProperty="false"/> 
    </jaxb:bindings> 
</jaxws:bindings> 

XJB (오류 : XSD 컴파일의 일부가 아닙니다) :

<jxb:bindings version="2.1" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <jxb:bindings schemaLocation="xsdschema.xsd"> 
     <jxb:bindings> 
      <jxb:globalBindings generateElementProperty="false"/> 
     </jxb:bindings> 
    </jxb:bindings> 
</jxb:bindings> 

메이븐 :

  <plugin> 
       <groupId>org.apache.cxf</groupId> 
       <artifactId>cxf-codegen-plugin</artifactId> 
       <version>${cxf.version}</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>wsdl2java</goal> 
         </goals> 
         <configuration> 
          <wsdlRoot>src/main/resources/wsdl</wsdlRoot> 
          <defaultOptions> 
           <bindingFiles>bindingFile>bindingFile.xjb</bindingFile> 
           </bindingFiles> 
          </defaultOptions> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
+0

이 문제가 해결 되었습니까? 그렇다면 어떻게 해결 했습니까? – Xstian

답변

2

나는이 전략을 제안합니다 ....

사용이 설정은 API를 생성 및 구성을 자원

<plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.1</version> 
       <executions> 
        <execution> 
         <id>add-source</id> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>add-source</goal> 
         </goals> 
         <configuration> 
          <sources> 
           <source>target/generated-sources/xjc</source> 
           <source>target/generated-sources/cxf</source> 
          </sources> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
를 추가 할 수

  <plugin> 
       <groupId>org.jvnet.jaxb2.maven2</groupId> 
       <artifactId>maven-jaxb2-plugin</artifactId> 
       <version>0.8.1</version> 
       <executions> 
        <execution> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>generate</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <args> 
         <arg>-Xannotate</arg> 
         <arg>-nv</arg> 
        </args> 
        <extension>true</extension> 
        <forceRegenerate>true</forceRegenerate> 
        <bindingDirectory>${basedir}/pathOfYourXJB</bindingDirectory> 
        <bindingIncludes> 
         <include>yourXJB.xjb</include> 
        </bindingIncludes> 
        <schemas> 
         <schema> 
          <fileset> 
           <directory>${basedir}/pathOfYourXSD</directory> 
           <includes> 
            <include>yourXSD.xsd</include> 
           </includes> 
          </fileset> 
         </schema> 
        </schemas> 
        <debug>true</debug> 
        <verbose>true</verbose> 
        <plugins> 
         <plugin> 
          <groupId>org.jvnet.jaxb2_commons</groupId> 
          <artifactId>jaxb2-basics</artifactId> 
          <version>0.6.2</version> 
         </plugin> 
         <plugin> 
          <groupId>org.jvnet.jaxb2_commons</groupId> 
          <artifactId>jaxb2-basics-annotate</artifactId> 
          <version>0.6.2</version> 
         </plugin> 
        </plugins> 
       </configuration> 
      </plugin> 

사용이 플러그인을 바인딩과 XSD 클래스를 생성하려면이 플러그인 XSD 클래스를

<plugin> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-codegen-plugin</artifactId> 
    <version>${cxf.version}</version> 
    <executions> 
     <execution> 
      <id>generate-sources</id> 
      <phase>generate-sources</phase> 
      <configuration> 
       <wsdlOptions> 
        <wsdlOption> 
         <wsdl>${basedir}/pathOfYourWSDL.wsdl</wsdl> 
         <extraargs> 
          <extraarg>-nexclude</extraarg> 
          <extraarg>http://somenamespace</extraarg>         
         </extraargs> 
        </wsdlOption>       
       </wsdlOptions> 
      </configuration> 
      <goals> 
       <goal>wsdl2java</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

사용을 제외 할

이 전략을 사용하여 데이터 모델을 API에서 나눕니다.