调用Python代码

外部Web服务目前我打电话命令行外部Web服务在Unix中:调用Python代码

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来调用Web服务。

回答:

我在我的网址前面的一个额外的双引号,这是造成这一问题的发生,这是正确的语法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'])

以上是 调用Python代码 的全部内容, 来源链接: utcz.com/qa/257950.html

回到顶部