1、建一个Project取名为SOAP
2、将axis-1_4\webapps\axis\WEB-INF\lib下的所有文件拷贝到你的SOAP工程文件下
3、新建一个HelloWord.java
package com;
public class HelloWord {
public String getHelloWord(userInfo userInfo) {
return "hi!:" + userInfo.getName() + "| " + userInfo.getPassword()
+ " | " + userInfo.getArea();
}
}
4、新建一个userInfo.java 对象
package com;
public class userInfo implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = -1536718814867769008L;
String name;
String password;
String area;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
}
5、在WEB-INF\server-config.wsdd 文件添加以下内容(注意颜色标记的地方时跟soap相关的地方)
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<handler type="java:org.apache.axis.handlers.http.URLMapper"
name="URLMapper" />
<service name="HelloWord" provider="java:RPC">
<parameter name="className" value="com.HelloWord" />
<parameter name="allowedMethods" value="getHelloWord" />
<beanMapping languageSpecificType="java:com.userInfo" qname="ns:userInfo" xmlns:ns="urn:BeanService"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper" />
</requestFlow>
</transport>
</deployment>
6、web.xml 内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>
7、访问路径 http://localhost:8080/SOAP/services/HelloWord?wsdl
8、使用soapUI 3.6.1 生成客户端JUNIT测试代码.进行单元测试!设置soapui的axis参数
9、生成客户端JUNIT测试代码
10、将生成的代码放到SOAP工程下。修改测试用例。
11、执行测试,查看结果: