2013-04-05 101 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

您可能需要为两个包创建两套编组/解除器/模板/客户端。