通过wsdl文件,逆向开发webservice服务端
通过wsdl文件,逆向开发webservice服务端
一、创建web项目
webservice是通过http/https协议访问,所以要创建web项目,这里按maven格式来创建web工程(见maven web工程步骤请看maven部分)。
二、根据wsdl文件,创建webservice客户端
2.1 选中工程test-axis1-client,右键 New->Other->Web Services->Web Service.
在Web service type下拉框选择:Top down java bean Web Service (自顶向下Web服务java bean,这个和上一篇的《eclipse开发webservice服务端是相反的》)。
在Service definition输入框输入:http://192.168.1.101:8080/test-axis1/services/UpayCsysTmallTxnLog?wsdl (服务端提供的wsdl访问地址,确保浏览器能访问这个地址)
2.2 点击【Next】按钮
2.3 按默认配置,继续点击【Next】
2.4 按默认配置,继续点击【Next】
2.5 按默认配置,继续点击【Finish】
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
<modelVersion>4.0.0</modelVersion>
-
<groupId>com.plg.webservice.axis</groupId>
-
<artifactId>test-axis1-client</artifactId>
-
<packaging>war</packaging>
-
<version>0.0.1-SNAPSHOT</version>
-
<name>test-axis1-client Maven Webapp</name>
-
<url>http://maven.apache.org</url>
-
<dependencies>
-
<dependency>
-
<groupId>junit</groupId>
-
<artifactId>junit</artifactId>
-
<version>3.8.1</version>
-
<scope>test</scope>
-
</dependency>
-
<dependency>
-
<groupId>axis</groupId>
-
<artifactId>axis</artifactId>
-
<version>1.4</version>
-
</dependency>
-
<dependency>
-
<groupId>commons-discovery</groupId>
-
<artifactId>commons-discovery</artifactId>
-
<version>0.2</version>
-
</dependency>
-
<dependency>
-
<groupId>org.apache.axis</groupId>
-
<artifactId>axis-jaxrpc</artifactId>
-
<version>1.4</version>
-
</dependency>
-
<dependency>
-
<groupId>org.apache.axis</groupId>
-
<artifactId>axis-saaj</artifactId>
-
<version>1.4</version>
-
</dependency>
-
<dependency>
-
<groupId>wsdl4j</groupId>
-
<artifactId>wsdl4j</artifactId>
-
<version>1.5.1</version>
-
</dependency>
-
</dependencies>
-
<build>
-
<finalName>test-axis1-client</finalName>
-
</build>
左边红色圈子中的文件都是自动生成的,是按照wsdl文件描述生成的。你会发现代码里有很多错误,那是没有引用响应的jar包,可以在pon.xml文件里加上必要的包,如下: