目前J2EE中使用的web serivce的主流技术有JAX-WS2.0, CXF, AXIS2等,这些技术都能作为WSDL1.1, 1,2服务器或者客户端。JAX-WS2.0, CXF, AXIS2这些技术各有优缺点, 相互之间也会有一些类库冲突,一般在一个公司内部都会采用欧一种技术作为web service的实现。我们用的是jboss 的jax-ws实现。
?
最近在项目中遇到了一个和billing system集成的任务, 这个系统发布得有6,7年了,用软件开发的术语来描述就是和Legacy System集成。从客户那边拿到了一个使用rpc/encoding作为binding style的wsdl文件,用这个wsdl生成客户端的stub类。尝试了jax-ws的wsimport,得到"jax ws - java: Rpc/encoded wsdls are not supported in JAXWS 2.0"的错误,wsimport不支持rpc/encoding。
?
说一下最终目标:
1)使用wsdl文件生成一个web service的服务器作为模拟器,用于集成测试
2)生成一个client,部署于jbossesb 4.8中作为客户端调用web serivce
?
通过比较最终得出
wsdl2java(AXIS2) 用于生成web service的服务器作为模拟器
wscompile(AXIS)? 生成客户端stub
?
Part 1 使用wsdl2java(AXIS2)生成web service的服务器作为模拟器
Use Axis2 to implement the axis web service:
1) Use Axis2 wsdl2java to generate source code(use ant in maven)
2) wsdl2java config: -ss -wsdl 1.1 ...
3) Add dependencies
4) copy generated xsd file to classes folder
5) copy wsdl file to
6) modify services.xml to use a mock service implemenation
<!-- The following dependencies are used to generate the server side source code from wsdl. -->
??? <dependency>
??? <groupId>wsdl4j</groupId>
??? <artifactId>wsdl4j</artifactId>
??? <version>1.6.2</version>
??? <type>jar</type>
??? <scope>compile</scope>
??? </dependency>
??? <dependency>
... ...
? </dependencies>
? <build>
??? <plugins>
??? <!--? use ant to call wsdl2java to generate the java source code, see detail in build.xml -->
????? <plugin>
??????? <artifactId>maven-antrun-plugin</artifactId>
??????? <executions>
????????? <execution>
??????????? <phase>generate-sources</phase>
??????????? <configuration>
??????????? <tasks>
????????????????? <property name="compile_classpath" refid="maven.compile.classpath"/>
????????????????? <ant antfile="${basedir}/build.xml" target="generate.server" />
???????????????? </tasks>
??????????? </configuration>
??????????? <goals>
????????????? <goal>run</goal>
??????????? </goals>
????????? </execution>
??????? </executions>
????? </plugin>
?????
????? <!-- add the generated source code to source path -->
????? <plugin>
??????? ... ...
????? </plugin>
?????
????? <!--? copy generated xsd files to WEB-INF/classes -->
????? <plugin>
??????? ... ...
????? </plugin>??
??? </plugins>
Use ant script to run wsdl2java to generate client side stub.
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpath="${compile_classpath}">
??????? <arg line="-uri ./src/main/webapp/WEB-INF/services/GreatLakes/META-INF/IOBISMSClient.wsdl" />
??????? <arg line="-s" />
????? <arg line="-ss" />
????? <arg line="-sd" />
????? <arg line="-wv 1.1" />
??????? <arg line="-l java" />
??????? <arg line="-p net.beaumaris.billing.gl.mockservice" />
??????? <arg line="-d xmlbeans" />
??????? <arg line="-o ./target/generated-sources/xjc" />
????? </java>
??? </target>
?
Part 2 使用wscompile(AXIS)? 生成客户端stub
?
TBD
?