2013-04-05 96 views
1

下面的問題,我有2個WSDL文件,我必須生成存根。但是這兩個WSDL文件都包含相同的XML類型名稱(第二個WSDL是第一個WSDL的另一個階段)。maven-jaxb插件 - 兩個類具有相同的XML類型名稱

我生成以下配置存根:

<plugins> 
    .. 
     <plugin> 
      <groupId>org.jvnet.jaxb2.maven2</groupId> 
      <artifactId>maven-jaxb2-plugin</artifactId> 
      <version>0.7.1</version> 
      <executions> 
       <execution> 
        <id>ws-source-gen-phase1</id> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <removeOldOutput>true</removeOldOutput> 
         <extension>true</extension> 
         <schemaDirectory>src/main/resources/META-INF/schema/xyz/</schemaDirectory> 
         <args> 
          <arg>-wsdl</arg> 
          <schemaFiles>src/main/resources/META-INF/schema/xyz/Service1.wsdl</schemaFiles> 
          <arg>-XautoNameResolution</arg> 
         </args> 
         <generatePackage>com.xyz.ws</generatePackage> 
         <generateDirectory>${project.build.directory}/generated-sources/xjc1</generateDirectory> 
        </configuration> 
       </execution> 
       <execution> 
        <id>ws-source-gen-phase2</id> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <removeOldOutput>true</removeOldOutput> 
         <extension>true</extension> 
         <schemaDirectory>src/main/resources/META-INF/schema/xyz/</schemaDirectory> 
         <args> 
          <arg>-wsdl</arg> 
          <schemaFiles>src/main/resources/META-INF/schema/xyz/Service2.wsdl</schemaFiles> 
          <arg>-XautoNameResolution</arg> 
         </args> 
         <generatePackage>com.xyz.ws.phase2</generatePackage> 
         <generateDirectory>${project.build.directory}/generated-sources/xjc2</generateDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

這確實產生我存根,但如果我嘗試用彈簧WS使用它們,我得到下面的錯誤。

的applicationContext.xml:

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> 

<bean id="xyzMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
    <property name="contextPath" 
     value="com.xyz.ws:com.xyz.ws.phase2" /> 
</bean> 
<bean id="xyzUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
    <property name="contextPath" 
     value="com.xyz.ws:com.xyz.phase2" /> 
</bean> 

<bean id="xyzServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> 
    <constructor-arg ref="messageFactory" /> 
    <property name="marshaller" ref="xyzMarshaller"></property> 
    <property name="unmarshaller" ref="xyzUnmarshaller"></property> 
    <property name="defaultUri" value="${ThiemeRightAccessService.URI}" /> 
</bean> 

<bean id="XyzServiceClient" 
    class="com.ebcont.gtv.radbase.business.service.impl.XyzServiceClientImpl"> 
    <constructor-arg ref="xyzServiceTemplate"></constructor-arg> 
</bean> 

錯誤:

Two classes have the same XML type name "{http://status.ws.xyz.com/}GetXyzObject1". Use 
@XmlType.name and @XmlType.namespace to assign different names to them. 
... 

回答

0

顯然,你不能混用com.xyz.wscom.xyz.ws.phase2 - JAXB不知道至極類創建爲{http://status.ws.xyz.com/}GetXyzObject1

您可能需要爲兩個包創建兩套編組/解除器/模板/客戶端。