连接到WebService

2024-05-08 16:00:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一些PHP代码,类似于下面所示的代码,它建立连接并获得响应(来自web服务)。在

如何在Python中执行类似的操作?在

$cObj = curl_init();.
curl_setopt($cObj, CURLOPT_URL,$this->urlws.'/trlink/link1/trlink');
curl_setopt($cObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cObj, CURLOPT_TIMEOUT, 20);
curl_setopt($cObj, CURLOPT_HTTPHEADER, array());

curl_setopt($cObj, CURLOPT_POST, 1);
curl_setopt($cObj, CURLOPT_POSTFIELDS,"XMLString=".$xml);

$this->xml_response = curl_exec($cObj);.

Tags: 代码weburlinitxmlcurlthisphp