簡體   English   中英

從Python代碼調用外部Web服務

[英]Call an external webservice from Python code

目前,我正在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,但是由於它是一個https調用,因此面臨着與ssl相關的多個問題。 現在我正在嘗試調用一個子流程模塊: 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

我將使用請求來調用該Web服務。

我的URL前面有一個額外的雙引號,導致發生此問題,這是正確的語法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'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM