如何避免CXF代码源更改架构中的元素名称?

时间:2018-10-23 16:08:01

标签: cxf

我在Maven项目中使用cxf-codegen-plugin v。3.2.4。 WSDL指的是模式:

<xsd:import namespace="http://mynamespace/"
                        schemaLocation="../schema/MySchema.xsd"/>

但是当生成的服务器运行时,已发布的wsdl指的是这样的架构:

<xsd:import namespace="http://mynamespace/" schemaLocation="http://localhost:9999/?xsd=1"/>

此生成的xsd更改了给定方法的参数名称。原始架构具有以下定义:

<xs:complexType name="myMethod">
        <xs:sequence>
            <xs:element name="messageHeader" type="tns:soapMessageHeader" minOccurs="0"/>
            <xs:element name="myId" type="xs:string" minOccurs="0"/>
            <xs:element name="mySecondId" type="xs:string" minOccurs="0"/>
            <xs:element name="myThirdId" type="xs:string" minOccurs="0"/>
            <xs:element name="password" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>

生成的架构具有以下内容:

<xs:complexType name="myMethod">
<xs:sequence>
   <xs:element name="arg0" type="tns:soapMessageHeader" minOccurs="0"/>
   <xs:element name="arg1" type="xs:string" minOccurs="0"/>
   <xs:element name="arg2" type="xs:string" minOccurs="0"/>
   <xs:element name="arg3" type="xs:string" minOccurs="0"/>
   <xs:element name="arg4" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

将元素名称从定义的名称更改为“ arg0”,“ arg ...”。我需要不要这样做。

我的pom有这个:

<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>
                            <sourceRoot>${source.wsdl.path}</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/wsdl/MyServiceDefinition.wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-impl</extraarg>
                                        <extraarg>-verbose</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

该服务的自动生成的界面带有@WebParam注释。

请问有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

我刚刚弄清楚了:尽管为服务生成的接口具有@WebParam批注,但是实现EndPoint的各个具体类却没有它。我认为这不会有问题,因为该接口具有注释。然后,我尝试将它们添加到参数中,然后添加!生成的xsd突然出现,我可以读取参数了!

答案 1 :(得分:0)

http://www.benmccann.com/web-services-tutorial-with-apache-cxf中,作者指出了使用 endpointInterface 注释属性,以便遵守自动生成的界面内部的注释(由cxf本身):

@WebService(endpointInterface = "com.company.auth.service.AuthService",
            serviceName = "corporateAuthService")

此替代方法不需要其他xml配置。

Tomcat EE文档为我们提供了一个完整的示例:http://tomee.apache.org/examples-trunk/simple-webservice

另一个可能与之相关的stackoverflow问题:jax-ws regarding endpointinterface

相关问题