1

以下问题,我有 2 个 WSDL 文件,我必须从中生成存根。但是两个 WSDL 文件都包含相同的 XML 类型名称(第二个 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 一起使用,我会收到以下错误。

应用程序上下文.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.
...
4

1 回答 1

0

显然你不能混合com.xyz.ws- com.xyz.ws.phase2JAXB 不知道要为{http://status.ws.xyz.com/}GetXyzObject1.

您可能需要为两个包创建两组 marshaller/unmarshaller/template/client。

于 2013-04-07T22:24:41.297 回答