• java 调用axis2 webservice


    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(); } }
  • 相关阅读:
    python实现的最近最少使用算法
    GreaseMonkey渐进
    SICP 与函数式编程
    python实现的简单的epub2txt
    智能去除选定区域
    ubuntu下svn上传到google code
    视频数据编解码技术
    分享三个好用的装饰器
    ubuntu下访问E72
    如何组织文件
  • 原文地址:https://www.cnblogs.com/xsmhero/p/5082532.html
Copyright © 2020-2023  润新知