使用Axis2生成soap客户端
来源:互联网 发布:cv2.calchist python 编辑:程序博客网 时间:2024/05/19 18:37
import java.io.DataOutputStream;import java.io.IOException;import java.io.UnsupportedEncodingException;import java.net.Socket;import java.net.UnknownHostException;import java.util.Properties;import org.apache.axiom.om.OMAbstractFactory;import org.apache.axiom.om.OMElement;import org.apache.axiom.om.OMFactory;import org.apache.axiom.om.OMNamespace;import org.apache.axis2.AxisFault;import org.apache.axis2.addressing.EndpointReference;import org.apache.axis2.client.Options;import org.apache.axis2.client.ServiceClient;/** * 发送soap工具类 * * @author wpj_service * */public class soapClient {private static final String url = "127.0.0.1:80";/** * * @return * @author wpj * @throws axisFault */public static String sendSoap() {String result = "";try {// ---------------------头-----------------------------------------------OMFactory factory = OMAbstractFactory.getOMFactory();OMNamespace SecurityElementNamespace = factory.createOMNamespace("http://www.baidu.com.cn/common/header/in", "in");OMElement soapHeader = factory.createOMElement("soapHeader",SecurityElementNamespace);OMNamespace SecurityElementNamespace1 = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");soapHeader.declareNamespace(SecurityElementNamespace1);OMElement head1 = factory.createOMElement("msgRef",SecurityElementNamespace);head1.setText("head1");soapHeader.addChild(head1);// ---------------------头end----------------------------------------------// ---------------------体-------------------------------------------------OMNamespace omNsBody = factory.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soap-env");OMElement soapBody = factory.createOMElement("Body", omNsBody);OMNamespace omNsTargetNs = factory.createOMNamespace("http://www.baidu.com.cn/card","targetNs");OMNamespace omNsHeader2 = factory.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soap");soapBody.declareNamespace(omNsTargetNs);soapBody.declareNamespace(omNsHeader2);soapBody.declareNamespace(omNsBody);OMElement soapTargetNs = factory.createOMElement("doProcessRequest", omNsTargetNs);OMElement body1 = factory.createOMElement("serviceCode",omNsTargetNs);body1.setText("body1");//创建一个两层的bodyOMElement body2 = factory.createOMElement("transactionDetails", omNsTargetNs);OMElement body21 = factory.createOMElement("phoneNo", omNsTargetNs);body21.setText("body21");body2.addChild(body21);soapTargetNs.addChild(body1);soapTargetNs.addChild(body2);// ---------------------体end------------------------Options options = new Options();EndpointReference targetEPR = new EndpointReference(url);options.setTo(targetEPR);options.setAction("targetNs:doProcessRequest");ServiceClient sender = new ServiceClient();sender.setOptions(options);sender.addHeader(soapHeader);OMElement reOME = sender.sendReceive(soapTargetNs);result = reOME.toString();} catch (AxisFault axisFault) {axisFault.printStackTrace();}return result;}
阅读全文
0 0
- 使用Axis2生成soap客户端
- 关于如何使用axis2生成客户端代码
- wsdl使用axis2 1.4.1 生成客户端
- 使用axis2生成webservice服务端和客户端
- 使用Axis2 wsdl2java命令生成webservice客户端
- axis2 生成客户端
- axis2生成客户端代码
- axis2生成客户端代码
- 使用Axis2提供SOAP服务
- 使用axis2解析wsdl反向生成webservice客户端
- 使用axis2,根据WSDL生成java客户端代码
- 使用axis2解析wsdl生成Webservice客户端代码
- 使用axis2解析wsdl生成Webservice客户端代码
- 使用axis2解析wsdl生成Webservice客户端代码
- 使用axis2,根据WSDL生成java客户端代码
- 使用axis2,根据WSDL生成java客户端代码
- webService-axis2方式生成客户端
- Intelidea生成Soap客户端代码
- 抽象工厂模式
- SpringMVC
- 关于 quartz 1.6.1 的一个死等问题,导致任务不执行
- Codeforces Round #286 div.2 D 505D. Mr. Kitayuta's Technology【强连通分量,弱联通分量】
- Linux命令之awk
- 使用Axis2生成soap客户端
- get_maincat()分类调用方法
- Nginx服务器安装,高性能的HTTP、TCP、反向代理、负载均衡等服务和配置
- 文章标题
- SWAT—Samba WEB管理工具
- 使用XDP(eXpress Data Path)防御DDoS攻击
- linux配置网络
- RTMPDump(libRTMP)源代码分析 2:解析RTMP地址——RTMP_ParseURL()
- HTML学习笔记(二)——HTML标题和段落