我必须使用curl和php调用soap web服务。 我试过这段代码:
$ch = curl_init();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd................</soapenv:Envelope>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
此代码运行良好,但我无法将结果打印为XML。
如果我使用其他客户端来调用相同的服务,我会获得XML响应(这是正确的)。为什么呢?