一种基于http协议使用WebService方法
安装这个就不用多说。
使用:
1.创建一个SOAP project
填入WSDL
然后会解析出来一些数据。找到我们想要对接的接口 比如我对接的方法是
双击打开是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:update_Lianbi_info>
<!--Optional:-->
<tem:USERID>?</tem:USERID>
<!--Optional:-->
<tem:SN>?</tem:SN>
<!--Optional:-->
<tem:OLD_LBSN>?</tem:OLD_LBSN>
<!--Optional:-->
<tem:NEW_LBSN>?</tem:NEW_LBSN>
</tem:update_Lianbi_info>
</soapenv:Body>
以及
</soapenv:Envelope>
这个就是我们即将需要的。
Java代码
public void SendLianbiWebService()throws ParseException,IOException {
HttpClient client = HttpClients.createDefault();
String reqSoapData = buildreqSoapData(liBiEntity);//此处就是拼接SOAP请求
HttpPost post = new HttpPost(WSDLURL);// WSDLURL 就是提供的WSDL
try {
httpentity re = new StringEntity(reqSoapData,"UTF-8");
post.setHeader("Content-Type","text/xml;charset=UTF-8");
post.setHeader("Accept-Encoding","gzip,deflate");
post.setHeader("SOAPAction","http://tempuri.org/IWarehouse_Business/update_change_Lianbi_info");
post.setEntity(re);
response = client.execute(post);//发送请求
returnInfo = EntityUtils.toString(response.getEntity());
log.info("请求服务返回XML文本:" + returnInfo);
} catch (UnsupportedEncodingException e) {
log.error(e.getStackTrace());
} catch (ClientProtocolException e) {
log.error(e.getStackTrace());
} catch (IOException e) {
log.error(e.getStackTrace());
}
}
下面介绍
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。