一.AXIS的安装
启动Tomcat服务器后打开浏览器输入网址http://localhost:8080/axis 后应该出现如下图所示页面,点击链接"Validate"来验证Axis所需的几个JAVA包是否齐全。
|
点击超链接Validate后,AXIS会自动检查所需的每一个JAVA组件,这些组件分为:必需组件以及可选组件,必须保证所有必需组件都存在,如下图所示即为验证失败。
|
|
|
下载activation.jar并拷贝到F:/TOMCAT4/common/lib下重新启动TOMCAT点击超链接Validate如下图所示即为验证成功。
|
|
一. Web Service服务端开发
1: Hello world程序
在F:/TOMCAT4/webapps/axis下新建Test.java
public class Test{ public String getMsg(){ System.out.println("happen act in getMsg()"); return "demo"; } public void setMsg(String msg){ //--operation here } } |
在浏览器输入网址http://127.0.0.1:8080/axis/Test.jws
显示如图片下图
为什么出错。对了我们应该把Test.java改名为Test.jws
在次在浏览器输入网址http://127.0.0.1:8080/axis/Test.jws
显示如下结果
There is a Web Service here |
点击页面上的链接查看该Web服务对应的WSDL信息如下所示
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://127.0.0.1:8080/axis/Test.jws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://127.0.0.1:8080/axis/Test.jws" xmlns:intf="http://127.0.0.1:8080/axis/Test.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:message name="setMsgResponse"> </wsdl:message> <wsdl:message name="getMsgResponse"> <wsdl:part name="getMsgReturn" type="xsd:string"/> </wsdl:message> <wsdl:message name="setMsgRequest"> <wsdl:part name="msg" type="xsd:string"/> </wsdl:message> <wsdl:message name="getMsgRequest"> </wsdl:message> <wsdl:portType name="Test"> <wsdl:operation name="getMsg"> <wsdl:input message="impl:getMsgRequest" name="getMsgRequest"/> <wsdl:output message="impl:getMsgResponse" name="getMsgResponse"/> </wsdl:operation> <wsdl:operation name="setMsg" parameterOrder="msg"> <wsdl:input message="impl:setMsgRequest" name="setMsgRequest"/> <wsdl:output message="impl:setMsgResponse" name="setMsgResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="TestSoapBinding" type="impl:Test"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getMsg"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getMsgRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="getMsgResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://127.0.0.1:8080/axis/Test.jws" use="encoded"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="setMsg"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="setMsgRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="setMsgResponse"> <wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/ namespace="http://127.0.0.1:8080/axis/Test.jws" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="TestService"> <wsdl:port binding="impl:TestSoapBinding" name="Test"> <wsdlsoap:address location="http://127.0.0.1:8080/axis/Test.jws"/> </wsdl:port> </wsdl:service> </wsdl:definitions> |
到此我们已经完成了hello的Web服务了