Python调用绑定配置为wsHttpBinding的WC

网上查询均说不行,捣鼓了一天,总算有些眉目。

import http.client

soap_body='''<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">
http://www.xxx.com/ISHWS/ChkReg
</a:Action><a:MessageID>urn:uuid:82989341-5861-49a4-bb93-c5edb9ec1497</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address></a:ReplyTo><a:To s:mustUnderstand="1">
http://www.xxx.com/SHWS/SHWS.svc/SHWS
</a:To></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ChkReg xmlns="http://www.xxx.com"><RegParem>
<strRegInfoValue xmlns="http://schemas.datacontract.org/2004/07/SHWS">函数参数</strRegInfoValue>
<strUserValue xmlns="http://schemas.datacontract.org/2004/07/SHWS">函数参数</strUserValue>
</RegParem></ChkReg>
</s:Body></s:Envelope>'''
#楼上Fiddle抓包来的
soap_body=soap_body.replace("\n", "").replace("\r","") #去除字符串中的回车换行
#楼下xx.xx.xx.xx 为IP地址
ws=http.client.HTTPConnection("xx.xx.xx.xx")
ws.putrequest("POST","/SHWS/SHWS.svc/SHWS","HTTP/1.1")
ws.putheader("Host","xx.xx.xx.xx") 
ws.putheader("Content-Type","application/soap+xml; charset=utf-8")
ws.putheader("Content-Length",len(soap_body))
ws.endheaders()
ws.send(soap_body.encode())
wr = ws.getresponse()
for i in wr:
    print(i)

#总结:1、调用的函数及其参数都在SOAP中,构造相应字符串POST过去,然后获取响应数据即可实现。
#2、还可进一步封装,那串uuid没用。
#3、wsHttpBinding仍为明文

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值