简体   繁体   中英

What is the correct way to rename JAX-WS service classes using codehaus jaxws-maven-plugin?

What is the correct to rename these classes? Using the config below, the classes are created ( Service1 and Service1Soap ) but Service1 is not named NewService as expected.

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>

For the customisations to occur correctly, I modified the bindings.xml file: using the jaxws namespace, rather than jaxb namespace for the class (and dropping the jaxb namespace altogether).

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM