Axis全称Apache eXtensible Interaction Systemapache组织下开源项目用来做webservice开发有java版实现也有c++版实现其前身早IBMSOAP4J来捐给Apache改名Apache SOAP也支持SOAP1.1版本现AXIS已经第三代了AXIS对Apache SOAP改进有多比用SAX代替前DOM增加对WSDL支持支持SOAP1.2等等使用axiseasyapache网站上把axis下载了(新版本1.2.1)把%AXIS_HOME%\webapps\axis整目录copytomcatwebapps目录下面启动tomcat浏览器输入http://localhost:8080/axis了上面说只axis运行起来了要想布置自己webserviceaxis支持两种方法:种用JWS(Java Web Service)好处只要有源码比说Hello.java,把改成Hello.jws放%TOMCAT_HOME%\webapps\axis目录下面搞定浏览器里面输入http://localhost:8080/axis/Hello.jws了足地方能配置地方有限(比说Hello.java里面所有public非static方法都会暴露)多东西没办法弄;第二种方法使用wsdd(web service deploy description)TOMCAT_HOME%\webapps\axis\WEB-INF目录下写deploy.wsdd和undeploy.wsdd文件通过java org.apache.axis.client.AdminClient deploy.wsdd搞定了卸载webservice用org.apache.axis.client.AdminClient undeploy.wsdd客户端输入http://localhost:8080/axis/services/Hello了介绍了部署webservice两种方法下面说说客户端访问方式也有两种种通过axis实现java里面JAX-RPC进行动态调用另外种通过服务器端产生wsdl文件利用WSDL2Java工具生成Client Stub访问通过JAX-RPC比较简单需要提供有SOAP router URLservice namespaceoperation nameoperation parameter typesoperation return types看看下面例子明白了: public SOAPWrapper() { String location = "http://localhost:8080/axis/services/BookService"; try { Service service = new Service(); call = (Call)service.createCall(); call.setTargetEndpointAddress(new url(/location)); } catch (Throwable t) { handleError("SOAPWrapper (constructor) had an Exception.",t); } } public void create(Book book) { try { call.removeAllParameters(); call.setOperationName("create"); call.addParameter("arg1",qn,ParameterMode.IN); call.setReturnType(XMLType.AXIS_VOID); call.invoke(new Object[] {book}); return; } catch (Throwable t) { handleError("SOAPWrapper (create) had an Exception.",t); return; } }程序Call和Service对JAX-RPCCall和Service具体实现:org.apache.axis.client.Call implements javax.xml.rpc.Callorg.apache.axis.client.Service implements javax.xml.rpc.Service第二种客户端方法利用WSDL2Java产生Client stub通过stub调用WSDL2Java操作对象service所对应wsdl文件文件产生呢种方法前面由axis自动产生前面服务器端配置所说无论通过jws或wsdd方式axis都会产生相应wsdl;还有种方式利用Java2WSDL对java源文件进行操作也产生相应wsdl文件
原文地址:http://www.cnblogs.com/houguiqiang/p/3813012.html