实际开发笔记:WebService接口调用一

最近在与其他系统联调,涉及到数据传输,沟通后,统一用WebService接口

WebService接口报文:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
   <soapenv:Header/>
   <soapenv:Body>
      <paos:Query soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <map xsi:type="x-:Map" xmlns:x-="http://xml.apache.org/xml-soap">
            <!--Zero or more repetitions:-->
            <item xsi:type="x-:mapItem">
               <key xsi:type="xsd:anyType">?</key>
               <value xsi:type="xsd:anyType">?</value>
            </item>
         </map>
      <paos:Query>
   </soapenv:Body>
</soapenv:Envelope>


private Map callWebService(String requestUri,Map params,String rovokeName) {
		Service service = new Service();// 创建一个服务(service)调用(call)  
		Map callRet= new HashMap();//返回串
		try {
			Call call = (Call)service.createCall();// 通过service创建call对象  
			call.setTargetEndpointAddress(new java.net.URL(requestUri));//设置service所在URL 
	        call.setOperationName(rovokeName);  //设置调用方法名 
	        call.setReturnClass(Map.class);
	        call.addParameter("params", XMLType.SOAP_MAP, ParameterMode.IN);
	        
	        log.debug("++++++++qryRegionName+start call+++++++++++");
	        callRet = (Map)call.invoke(new Object[]{params});   
	        log.debug("++++++++qryRegionName+callRet+++++++++++"+callRet);
	        return callRet;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return callRet;  
	}


上面是自己研究的调用方法,只需输入入参,地址,和方法名即可调用。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值