package example.client;<o:p></o:p>
<o:p> </o:p>
import org.apache.axiom.om.OMAbstractFactory;<o:p></o:p>
import org.apache.axiom.om.OMElement;<o:p></o:p>
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;<o:p></o:p>
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;<o:p></o:p>
import org.apache.axis2.client.ServiceClient;<o:p></o:p>
<o:p> </o:p>
public class TestClient {<o:p></o:p>
// targetEPR指定打包的Service(.aar文件)在容器中的物理位置。<o:p></o:p>
private static EndpointReference targetEPR=new EndpointReference
("http://localhost:8080/axis2/services/HelloWorld");
public static OMElement getSayHelloOMElement(){
//创建request SOAP包。
OMFactory fac=OMAbstractFactory.getOMFactory();
// OMNamespace指定此SOAP文档名称空间。
OMNamespace omNs=fac.createOMNamespace("http://helloworld.com/","hw");<o:p></o:p>
//创建元素sayHello,并指定其在omNs指代的名称空间中。<o:p></o:p>
OMElement method=fac.createOMElement("sayHello",omNs);
//指定元素的文本内容。
method.setText("ZJ");
return method;
}
public static void main(String[] args){
try{
Options options=new Options();
options.setTo(targetEPR);
ServiceClient sender=new ServiceClient();
sender.setOptions(options);
OMElement sayHello=TestClient.getSayHelloOMElement();
//发出request SOAP,
//同时将得到的远端由sayHello方法返回的信息保存到result。
//通过services.xml能准确找到sayHello方法所在的文件。
OMElement result=sender.sendReceive(sayHello);
}
catch(Exception axisFault){
axisFault.printStackTrace();
}
}
}
|
相关推荐
NULL 博文链接:https://helloklzs.iteye.com/blog/1050070
NULL 博文链接:https://tw5566.iteye.com/blog/324072
基于_Tomcat5.0和_Axis2开发Web_Service应用实例
Axis+MyEclipse6.0+Tomcat5.0开发Web Service实例总结
基于Tomcat5_0和Axis2开发Web Service应用实例,上面的例子简单实用
用axis2开发web service,过程比用axis1开发web service简单
基于AXIS2实现Web Service开发
随着Web Service技术迅速发展,基于Web Service开发的应用被使用...本文将介绍如何使用WAS CE(WebSphere Application Server Community Edition)和Apache Axis2开发、部署及测试一个简单的Web Service应用-网上花店。
基于Axis2和Tomcat的自动化可配置Web Service开发文档,源码和测试工程代码,详细讲述了如何在Tomcat环境下利用Axis2引擎快速开发一个可配置的自动化发布的web service应用。
基于Axis2的Web Service 快速开发.ppt
Axis开发Web Service实例,介绍AXIS的三种方法
文将介绍如何使用Tomcat5.0和Apache Axis2开发、部署及测试一个简单的Web Service应用
一个完整的web项目 基于axis2的web服务开发 包含完整代码和文档以及操作指南 请勿随意转载上传 所用到的其他技术包括但不限于:java web、mysql、Axis2、Html5、CSS2等 所用到的工具包括但不限于:eclipse、 Photo...
java基于Axis2调用C#开发的web service获取xml结果
web service在web接口系统中是jms中很不错的一个选择。而axis又是开发web service的不二人选。本文通过理论结合实例的方式讲解如何通过axis来开发web service。所有实例代码均可copy运行成功。
Axis2创建web service快速入门
在eclipse中用axis2开发Web Service,加快开发速度