Postman SOAP请求有效,但CURL没有

时间:2018-05-17 12:36:55

标签: php curl soap

我试图通过PHP实现AAA Cooper Freight的SOAP API。 当我向http://wsportal.aaacooper.com:8188/wsportal20/wsGenEst发送XML请求时,它通过Postman工作正常,但是当使用CURL时,它不会返回任何内容

我使用直接url(来自wsdl文件),因为它们的WSDL文件似乎被破坏而且它无法使用它: http://wsportal.aaacooper.com:8188/wsGenRateEstimate.wsdl

这是Postman的截图(工作!) enter image description here 和我的PHP代码:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,            "http://wsportal.aaacooper.com:8188/wsportal20/wsGenEst" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST,           1 );
curl_setopt($ch, CURLOPT_POSTFIELDS,     $input_xml ); 
curl_setopt($ch, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml; charset=ISO-8859-1')); 
$data = curl_exec($ch);
print_r($data);
curl_close($ch);

我在这两个地方使用相同的XML字符串。

1 个答案:

答案 0 :(得分:3)

Postman可以使用屏幕右上角的Code按钮为任何给定的请求生成PHP代码。可以在下图中看到此功能的演示。

Postman generated code

相关问题