重命名这些类的正确方法是什么?使用下面的配置,将创建类(Service1
和Service1Soap
),但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>
答案 0 :(得分: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>