問題に続いて、スタブを生成する必要がある 2 つの WSDL ファイルがあります。ただし、どちらの WSDL ファイルにも同じ XML タイプ名が含まれています (2 番目の WSDL は、最初の WSDL のさらに進んだ段階です)。
次の構成でスタブを生成します。
<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>
これにより実際にスタブが生成されますが、それらを spring-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.
...