我需要一些帮助,向Fedex发送SOAP请求以检索LTL费率报价。
目前我使用cURL发布XML,但无法使用simplexml_load_string解析响应。回应只是乱七八糟的混乱。
我正在寻找一个有同样问题的论坛,他说他只能通过使用SOAP发送请求来解决问题,但我不知道从哪里开始。
在这一点上我真的很绝望,因为我已经尝试了一百万种方法让它发挥作用而我无法做到。
请帮忙!
代码:
$URL = "https://ws.fedex.com:443/xml";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$status = $info['http_code'];
echo $status;
echo '<pre>';
$xml = simplexml_load_string($output);
var_dump($output);
部分回复:
200
string(13603) "
SUCCESSSUCCESScrs0Request was successfully processed. Request was successfully processed.
crs
14
0
0
FEDEX_FREIGHT_ECONOMYMON2013-09-23T17:00:00-05:00FEDEX_FREIGHT_ECONOMY2013-09-23T17:00:00-05:00MONTHREE_DAYS00FEDEX_FREIGHT_ECONOMY24.0MIP0DT00H43MSTANDARDYNGJOHN MURPHY888-229-0759330-538-0398415 S BAILEY RDNORTH JACKSONOH4