我试图用PHP中的cURL调用xml api调用。下面是代码。但是我没有得到任何回应。尝试使用curl_error()
来获取错误。但是没有发现错误。
$url='http://test.*******.com:8013/WCAPI.svc';
$input_xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:wpb="http://schemas.datacontract.org/2004/07/WPBusinessLayer.WPTransactionLayer.WebconnectPlus.Corporate.Agent.User.Proxy">
<soapenv:Header/>
<soapenv:Body>
<tem:ProcessUserLogin>
<tem:ObjCRPUserLoginReq>
<wpb:AUI>333</wpb:AUI>
<wpb:Password>apitest</wpb:Password>
<wpb:SID>CRPUSERLOGIN</wpb:SID>
<wpb:UTL>987639</wpb:UTL>
<wpb:UserName>apitest</wpb:UserName>
</tem:ObjCRPUserLoginReq>
</tem:ProcessUserLogin>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
'Content-type: text/xml; charset=utf-8',
'Content-length: '.strlen($input_xml),
'SOAPAction: http://tempuri.org/IWCAPI/ProcessUserLogin'
);
$ch= curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($input_xml));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if (curl_error($ch)) {
echo 'error:' . curl_error($ch);
}
curl_close($ch);
echo($data);
但是我没有得到任何回应。请帮助