无法跟踪XML API错误

时间:2015-09-21 06:39:43

标签: php xml web-services rest

我正在尝试集成运输API,但它不起作用,也没有返回任何错误。我想要实现的是,我将客户送货数据以xml格式发送到API网址,它将创建一个货件并返回我的送货跟踪编号。但它没有工作,无法追踪任何错误,如果有的话。你能帮忙检查一下代码,告诉我是否有问题。

信息:这是一段代码,因为我开始工作,我将把它与magento发货方法集成。

这是我的代码..

$xmlns = [
  'soap' => 'http://www.w3.org/2003/05/soap-envelope',     
  't' => 'http://tempuri.org/'
];
$xml = new SimpleXMLElement(
  '<?xml version = "1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" />'
);
$body = $xml->addChild("soap:Body", null, $xmlns['soap']);

$shipInfo = $body->addChild('InsertData', null, $xmlns['t']);
$shipInfo->addChild('auserName', "testuser");
$shipInfo->addChild('apassword', "testpass");

$shipInfo->addChild('acostCenterCode', "CC001");
$shipInfo->addChild('aconsigneeName', "Shipping TESTING");
$shipInfo->addChild('aconsigneeAddress', "Ship Demo Address");
$shipInfo->addChild('aconsigneeMobNo', "01801234577");
$shipInfo->addChild('aconsigneeEmail', "shiptesting@testing.com");
$shipInfo->addChild('aoriginCityName', "NY");
$shipInfo->addChild('adestinationCityName', "CA");
$shipInfo->addChild('apieces', "1");
$shipInfo->addChild('aweight', "1");
$shipInfo->addChild('acodAmount', "0");
$shipInfo->addChild('acustRefNo', "WebW");
$shipInfo->addChild('aproductDetails', "Test Product");
$shipInfo->addChild('afragile', "0");
$shipInfo->addChild('aservices', "0");
$shipInfo->addChild('aremarks', "Testing API services");
$shipInfo->addChild('ainsuranceValue', "0");


$xmlRequest = $xml->asXML();


try {
  //header('Content-type: text/xml');
  $testUrl = "http://255.255.255.255:3232";

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $testUrl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
  $xmlResponse = curl_exec ($ch);

  $debugData['result'] = $xmlResponse;
} catch (Exctption $e){
  $debugData['result'] = array('error' => $e->getMessage(), 'code' => curl_errno($ch));
  $xmlResponse = '';
}
print($debugData['result']);

curl_close($ch);

谢谢,

0 个答案:

没有答案