【问题标题】:What is the correct way to rename JAX-WS service classes using codehaus jaxws-maven-plugin?使用 codehaus jaxws-maven-plugin 重命名 JAX-WS 服务类的正确方法是什么?
【发布时间】:2017-03-09 08:36:16
【问题描述】:

重命名这些类的正确方法是什么?使用下面的配置,创建了类(Service1Service1Soap),但 Service1 未按预期命名为 NewService

wsdl

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://uo.isis.stfc.ac.uk/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://com.example.target.namespace/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  ...
  <wsdl:service name="Service1">
    <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
      <soap:address location="http://example.com/wsdl" />
    </wsdl:port>
    <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
      <soap12:address location="http://example.com/wsdl" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

bindings.xml

<jaxws:bindings
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
         xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">

    <jaxws:bindings node="wsdl:definitions/wsdl:service[@name='Service1']">
        <jaxb:class name="NewService"/>
    </jaxws:bindings>
</jaxws:bindings>

pom.xml

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.4.1</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>wsimport</goal>
            </goals>
            <configuration>
                <packageName>com.example.custom.package</packageName>
                <wsdlFiles>
                    <wsdlFile>path/to/wsdl</wsdlFile>
                </wsdlFiles>
                <bindingDirectory>
                    src/wsdl
                </bindingDirectory>
                <bindingFiles>
                    <bindingFile>
                        path/to/bindings.xml
                    </bindingFile>
                </bindingFiles>
            </configuration>
        </execution>
        <execution>
            ...
        </execution>
    </executions>
    <configuration>
        <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
        <xnocompile>false</xnocompile>
        <xendorsed>true</xendorsed>
        <extension>true</extension>
        <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
        <args>
            <arg>-B-XautoNameResolution</arg>
        </args>
        <vmArgs>
            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
        </vmArgs>
    </configuration>
</plugin>

【问题讨论】:

    标签: java maven jaxb jax-ws


    【解决方案1】:

    为了正确进行自定义,我修改了bindings.xml 文件:使用jaxws 命名空间,而不是jaxb 命名空间作为类(并完全删除jaxb 命名空间)。

    <bindings
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns="http://java.sun.com/xml/ns/jaxws">
    
        <bindings node="wsdl:definitions/wsdl:service[@name='Service1']">
            <class name="NewService"/>
        </bindings>
    </bindings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 2011-03-28
      • 2018-06-05
      • 2015-05-21
      相关资源
      最近更新 更多