python - 从 Python 代码调用外部 Web 服务

标签 python web-services curl

目前我正在 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/

相关文章:

web-services - 通过 Web 服务将 SharePoint 文档列表添加到快速启动

android - 通过 android 将图像上传到 RESTful web 服务,给出 NoSuchMethodError

python - 为什么此代码返回 'complex' ?

spring - 如何确保 https 仅用于 apache tomcat 中的某些 Web 服务

python - 是否有处理 "...more"的 Django 模板过滤器,当您单击它时,它会显示更多文本?

php - 使用 SFTP 和 cURL 获取文件

php - 如何处理 CURL 中服务器重置的连接

iis - 即使添加到 curl-ca-bundle.crt,curl openssl 也无法验证 IIS 7 自签名证书

python - Python中的多线程(我的代码正确)

javascript - 我可以在 JavaScript 中为实时音频流添加效果吗