使用wsimport或jaxws-maven-plugin生成web service代码
1.关于jax-ws web service client的代码生成,可以用JDK自带的wsimport。
我们可以写一个ant文件build.xml
<project default="save-wsdl"><property name="wsimport-path" value="C:/jdk1.6.0_33/bin/wsimport" /><property name="wsurl" value="http://localhost:8080/webservice-server/services" /><target name="wsimport"><exec executable="${wsimport-path}"><arg line="-keep -s ./src/main/java -p com.xpen.webservice.client ${wsurl}/MyService?wsdl" /></exec></target><target name="save-wsdl"><property name="wsdlfile" value="src/main/resources/wsdl/MyService.wsdl"/><property name="xsdfile" value="src/main/resources/wsdl/MyService.xsd"/><get src="${wsurl}/MyService?wsdl" dest="${wsdlfile}"/><get src="${wsurl}/MyService?xsd=MyService_schema1.xsd" dest="${xsdfile}"/></target></project>
<!-- jaxws Plugin --><plugin><groupId>org.jvnet.jax-ws-commons</groupId><artifactId>jaxws-maven-plugin</artifactId><version>2.1</version><executions><execution><goals><goal>wsimport</goal></goals></execution></executions><configuration><packageName>com.xpen.webservice.client</packageName><wsdlDirectory>src/main/resources/wsdl</wsdlDirectory><wsdlFiles><wsdlFile>MyService.wsdl</wsdlFile></wsdlFiles><bindingDirectory>src/main/resources/wsdl</bindingDirectory><bindingFiles><bindingFile>MyService.xsd</bindingFile></bindingFiles></configuration></plugin>