zoukankan      html  css  js  c++  java
  • 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(); } }
  • 相关阅读:
    [NOI Online 2021 提高组] 愤怒的小 N
    CF1474F 1 2 3 4 ...
    CF1466H Finding satisfactory solutions
    CF1336F Journey
    [PKUSC2021]代金券
    如何科学地设计对拍随机种子
    CF1168E Xor Permutations
    「JOISC 2019 Day2」两种运输
    springboot json参数
    springboot整合webserver应用
  • 原文地址:https://www.cnblogs.com/xsmhero/p/5082532.html
Copyright © 2011-2022 走看看