目前我正在 Unix 中从命令行调用外部 Web 服务:
curl --cert externalcertificate.cer --data @SampleRequest.xml -v https://world-service-dev.intra.a.com:4414/worldservice/CLIC/CaseManagementService/V1
我需要将此调用集成到我的 python 代码中。然后我将在其周围放置重试逻辑和响应验证,进行此调用的最佳方式是什么?由于它是单向 SSL,我还需要确保我的 Web 服务调用也引用了保存在我的服务器上的外部服务器证书。
我无法使用Python的请求模块,因为它没有安装在服务器上,我尝试使用urllib2,但面临与ssl相关的多个问题,因为它是一个https调用。
现在我尝试调用子流程模块:
subprocess.call(['curl', '-k', '-H' , 'content-type: application/soap+xml' ,'-d', etree.tostring(tree), '-v' ,'"https://world-service-dev.intra.aexp.com:4414/worldservice/CLIC/CaseManagementService/V1"'])
但收到错误消息:
* Protocol "https not supported or disabled in libcurl
curl: (1) Protocol "https not supported or disabled in libcurl
最佳答案
我会使用Requests调用该网络服务。
关于python - 从 Python 代码调用外部 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28682738/