【发布时间】:2018-10-27 17:38:04
【问题描述】:
我正在尝试通过 PHP 实现 AAA Cooper Freight 的 SOAP API。 当我通过 Postman 向 http://wsportal.aaacooper.com:8188/wsportal20/wsGenEst 发送 XML 请求时,它工作正常,但使用 CURL 时,它不返回任何内容
我使用直接 url(来自 wsdl 文件),因为他们的 WSDL 文件似乎已损坏并且无法使用: http://wsportal.aaacooper.com:8188/wsGenRateEstimate.wsdl
这是 Postman 的截图(正在工作!) 和我的 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 字符串。
【问题讨论】:
-
2 件事,将您遇到的错误添加到 OP,“不起作用”不是一个好的描述:p。 2) 在邮递员上,您发送一个带有 UTF-8 编码的 XML,但在 curl 中 Content -type 标头显示
charset=ISO-8859-1。服务器可能会或可能不会忽略这一点,因此它可能会中断请求。