1、按照需要写好服务端的bo
2、根据bo生成wsdl文件
2.1、在你的eclipse或myeclipse的项目中找到你引入的 axis.jar包,打开它,在其里面找到 org.apache.axis.wsdl下面的Java2WSDL类,然后以 Java application方式运行一下它 。
2.2、打开菜单栏“run”-->“Debug”,在弹出框的左边找到“Java Application”项,在其里面你会看到 “Java2WSDL”子项,点击它---> 在右面“Main”选项下有:“Project -- '你的项目名称' , Main class -- 'org.apache.axis.wsdl.Java2WSDL'”,这些信息是自动进去的,不需要改动;打开“Arguments”选项, 在其下“Program arguments”中输入:
Java代码
-d -l"http://127.0.0.1:8080/TestWebService/services/SayHello" -o "sayHello.wsdl" com.test.SayHello
然后点击"Debug"按钮,就可以生成你要的wsdl文件了。
3、根据wsdl文件生成客户端代码
把下面的jar包放在一个文件夹里,在该文件夹下创建一个bat文件写入以下代码,双击运行。
java -cp commons-discovery-0.2.jar;javax.jms.jar;saaj.jar;axis.jar;commons-logging- 1.0.4.jar;log4j-1.2.8.jar;activation.jar;jaxrpc.jar;mailapi_1_3_1.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java -p com.zlw.client.user UserManager.wsdl
4、生成server-config.swdd文件
java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
5、在服务端的web.xml中添加axis相应的配置,并且把server-config.wsdd放在web-inf下
<display-name>Apache-Axis</display-name>
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</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>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<!-- uncomment this if you want the admin servlet -->
<!--
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
-->
6、本人测试的时候返回String类型的可以,自定义的对象列表不可以。
2、根据bo生成wsdl文件
2.1、在你的eclipse或myeclipse的项目中找到你引入的 axis.jar包,打开它,在其里面找到 org.apache.axis.wsdl下面的Java2WSDL类,然后以 Java application方式运行一下它 。
2.2、打开菜单栏“run”-->“Debug”,在弹出框的左边找到“Java Application”项,在其里面你会看到 “Java2WSDL”子项,点击它---> 在右面“Main”选项下有:“Project -- '你的项目名称' , Main class -- 'org.apache.axis.wsdl.Java2WSDL'”,这些信息是自动进去的,不需要改动;打开“Arguments”选项, 在其下“Program arguments”中输入:
Java代码
-d -l"http://127.0.0.1:8080/TestWebService/services/SayHello" -o "sayHello.wsdl" com.test.SayHello
然后点击"Debug"按钮,就可以生成你要的wsdl文件了。
3、根据wsdl文件生成客户端代码
把下面的jar包放在一个文件夹里,在该文件夹下创建一个bat文件写入以下代码,双击运行。
java -cp commons-discovery-0.2.jar;javax.jms.jar;saaj.jar;axis.jar;commons-logging- 1.0.4.jar;log4j-1.2.8.jar;activation.jar;jaxrpc.jar;mailapi_1_3_1.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java -p com.zlw.client.user UserManager.wsdl
4、生成server-config.swdd文件
java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
5、在服务端的web.xml中添加axis相应的配置,并且把server-config.wsdd放在web-inf下
<display-name>Apache-Axis</display-name>
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</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>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<!-- uncomment this if you want the admin servlet -->
<!--
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
-->
6、本人测试的时候返回String类型的可以,自定义的对象列表不可以。