博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java 调用axis2 webservice
阅读量:7094 次
发布时间:2019-06-28

本文共 1950 字,大约阅读时间需要 6 分钟。

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;import org.apache.axis2.transport.http.HTTPConstants;

 

public static void invokeRemoteFuc2() throws Exception {        EndpointReference targetEPR = new EndpointReference("http://10.0.5.115/brm/services/RuleEngine1374389539674484");        Options options = new Options();        options.setAction("http://tempuri.org/getSerTypeList");// 调用接口方法        options.setTo(targetEPR);        options.setProperty(HTTPConstants.CHUNKED, "false");// 设置不受限制.        ServiceClient sender = null;        try {            sender = new ServiceClient();            sender.setOptions(options);            OMFactory fac = OMAbstractFactory.getOMFactory();            OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", "");            OMElement method = fac.createOMElement("getSerTypeList", omNs);            OMElement name = fac.createOMElement("prestr", omNs);// 设置入参名称            OMElement name2 = fac.createOMElement("key", omNs);// 设置入参名称            name.setText("hawei");// 设置入参值            name2.setText("6181a1fb89564b589283ad578baa7d5e");            //method.addChild(name);            //method.addChild(name2);            method.build();            System.out.println("method:" + method.toString());            OMElement response = sender.sendReceive(method);            System.out.println("response:" + response);            OMElement elementReturn = response.getFirstElement();            System.out.println("cityCode:" + elementReturn.getText());        } catch (AxisFault e) {            System.out.println("Error");            e.printStackTrace();        }    }

 

转载于:https://www.cnblogs.com/xsmhero/p/5082532.html

你可能感兴趣的文章
关于阿里云主机数据丢失问题,是常态还是个例?如何保障数据安全?
查看>>
Thinking in java(1):对象导论
查看>>
Powershell快速入门(一) 安装和使用
查看>>
11.OkHttp之java网络编程
查看>>
微博(APP)榜单爬虫及数据可视化
查看>>
Derek解读Bytom源码-创世区块
查看>>
常用的HTTP状态码
查看>>
快看!这个机器人穿着人类的鞋子在走路
查看>>
数据中心产业的五大现象
查看>>
搭建git私服
查看>>
安卓应用安全指南 4.3.2 创建/使用内容供应器 规则书
查看>>
PhpStorm PHP开发神器
查看>>
django 1.8 官方文档翻译:13-12 验证器
查看>>
有了这款虚拟现实头盔,用眼神就能控制无人机
查看>>
SpringBoot拦截器
查看>>
黑客分分钟劫持无人机,安全隐患不可小觑
查看>>
深入解析Spring架构与设计原理-数据库的操作实现
查看>>
初学者学习C++的50条忠告
查看>>
EMC连续四年位居魔力象限领导者位置,持续更新全闪存技术
查看>>
postgresql 查看系统中的锁信息与锁资源
查看>>