Ish*_*pta 4 python subprocess python-2.7
我从我的Python代码中调用web服务:
response = subprocess.call(['curl', '-k', '-i', '-H' , 'content-type: application/soap+xml' ,'-d', etree.tostring(tree), '-v' ,'https://world-service-dev.intra.aexp.com:4414/worldservice/CLIC/CaseManagementService/V1'])
Run Code Online (Sandbox Code Playgroud)
该服务返回一条soap消息,如何解析soap消息并查明它是失败还是成功?
我尝试使用以下内容,但结果错误:
subprocess.check_output("curl -k --data "+etree.tostring(tree)+"@SampleRequest.xml -v https://world-service-dev.intra.aexp.com:4414/worldservice/CLIC/CaseManagementService/V1",stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Run Code Online (Sandbox Code Playgroud)
不要PIPE
只是调用check_output
传递args列表并删除shell=True
:
out = subprocess.check_output(["curl", "-k","--data", etree.tostring(tree)+"@SampleRequest.xml", "-v", "https://world-service-dev.intra.aexp.com:4414/worldservice/CLIC/CaseManagementService/V1"])
Run Code Online (Sandbox Code Playgroud)
如果你得到一个非零的退出代码,你会得到一个CalledProcessError
.
归档时间: |
|
查看次数: |
1260 次 |
最近记录: |