3

我正在测试 Temando API 并尝试创建预订。我已按照他们的手册 Temando API R1_11 开发人员指南给出的说明进行操作。

我的问题是,当我使用以下必需信息创建调用 makeBookingByRequest 时:任何东西、任何地方、任何时间、一般、来源、目的地、报价、付款、说明、评论、促销代码。

它返回错误 500:内部服务器错误。如果这与许可有关,我已经解决了。

顺便说一下,这是我的其余代码:

ini_set("soap.wsdl_cache_enabled", "1");
$client = new SoapClient("https://training-api.temando.com/schema/XXXX/server.wsdl", array('soap_version' => SOAP_1_2));

$username = "xxxxxxxxxx";
$password = "xxxxxxxxxx";

$headerSecurityStr = "<Security><UsernameToken><Username>".$username."</Username><Password>".htmlentities($password)."</Password></UsernameToken></Security>";

$headerSecurityVar = new SoapVar($headerSecurityStr, XSD_ANYXML);

$soapHeader = new SoapHeader('wsse:http://schemas.xmlsoap.org/ws/2002/04/secext', 'soapenv:Header', $headerSecurityVar);

$client->__setSoapHeaders(array($soapHeader));

$destination = array();
$destination["destinationCountry"] = "AU";
$destination["destinationCode"] = "2000";
$destination["destinationSuburb"] = "Sydney";
$destination["destinationIs"] = "Residence";
$destination["destinationResPostalBox"] = "N";
$destination["destinationResUnattended"] = "N";
$destination["destinationResInside"] = "N";
$destination["destinationResLimitedAccess"] = "N";
$destination["destinationResHeavyLift"] = "N";

$origin = array();
$origin["originDescription"] = "ABC Suppliers";
$origin["originBusUnattended"] = "N";
$origin["originBusInside"] = "N";
$origin["originBusHeavyLift"] = "N";
$origin["originBusTailgateLifter"] = "N";
$origin["originBusContainerSwingLifter"] = "N";

$quote = array();
$quote["totalPrice"] = "110.00";
$quote["basePrice"] = "100.00"; 
$quote["tax"] = "10.00";
$quote["currency"] = "AUD";
$quote["deliveryMethod"] = "Off-peak";
$quote["etaFrom"] = "2";
$quote["etaTo"] = "3"; 
$quote["guaranteedEta"] = "Y";

$payment = array();
$payment["paymentType"] = "Credit Card";
$payment["cardType"] = "Mastercard";
$payment["cardExpiryDate"] = "05-2010";
$payment["cardNumber"] = "5163190000000000";
$payment["cardName"] = "JANE DOE";

$comments = "No Comment";
$reference = "ABC200000";

$makeBookingByRequest = array();
$makeBookingByRequest["anything"] = $anything1;
$makeBookingByRequest["anytime"] = $anytime;
$makeBookingByRequest["anywhere"] = $anywhere;
$makeBookingByRequest["general"] = $general;
$makeBookingByRequest["origin"] = $origin;
$makeBookingByRequest["destination"] = $destination;
$makeBookingByRequest["quote"] = $quote; 
$makeBookingByRequest["payment"] = $payment; 
$makeBookingByRequest["instructions"] = $instructions;
$makeBookingByRequest["comments"] = $comments; 
$makeBookingByRequest["reference"] = $reference; 

$anythings = array();

$anything1 = array();
$anything1["class"] = "Freight";
$anything1["mode"] = "Less than load";
$anything1["packaging"] = "Carton";
$anything1["qualifierFreightGeneralFragile"] = "N"; 
$anything1["distanceMeasurementType"] = "Centimetres"; 
$anything1["weightMeasurementType"] = "Kilograms";
/** get the data below from POST DATA **/
$anything1["length"] = "30";
$anything1["width"] = "10";
$anything1["height"] = "10";
$anything1["weight"] = "10";
$anything1["quantity"] = "1";
$anything1["description"] = "Contains bottle lids and liquors.";
/*****************/

array_push($anythings, $anything1);

$anywhere = array();
$anywhere["itemNature"] = "Domestic";
$anywhere["itemMethod"] = "Door to Door";

$anywhere["originCountry"] = "AU";
$anywhere["originCode"] = "4000";
$anywhere["originSuburb"] = "Brisbane";
$anywhere["originIs"] = "Business";
$anywhere["originBusUnattended"] = "N";
$anywhere["originBusDock"] = "Y";
$anywhere["originBusForklift"] = "N";
$anywhere["originBusLoadingFacilities"] = "N";
$anywhere["originBusInside"] = "N";
$anywhere["originBusLimitedAccess"] = "N";
$anywhere["originBusHeavyLift"] = "N";
$anywhere["originBusTailgateLifter"] = "N";
$anywhere["originBusContainerSwingLifter"] = "N";

$anywhere["destinationCountry"] = "AU";
$anywhere["destinationCode"] = "2000";
$anywhere["destinationSuburb"] = "Sydney";
$anywhere["destinationIs"] = "Residence";
$anywhere["destinationResPostalBox"] = "N";
$anywhere["destinationResUnattended"] = "N";
$anywhere["destinationResInside"] = "N";
$anywhere["destinationResLimitedAccess"] = "N"; 
$anywhere["destinationResHeavyLift"] = "N";

$anytime = array();
$anytime["readyDate"] = "2012-06-01";
$anytime["readyTime"] = "PM";

$general = array();
$general["goodsValue"] = "2000.00";

调用方法:

try{
    $makeBookingByRequestResponse = $client->makeBookingByRequest($makeBookingByRequest);
    p($makeBookingByRequestResponse);
}catch (SoapFault $exception){
    p($exception);
// Nothing is done with the exception yet. Will be processed later in the display code.
}

function p($arr){
    echo '<pre>';
    print_r($arr);
    echo '</pre>';  
}

有没有人有使用 Temando API 的经验?任何帮助,将不胜感激。

4

1 回答 1

0

尝试使用soapUI创建您的 SOAP 请求。它是一个免费软件,对处理 SOAP Web 服务非常有用。当它工作时,您可以专注于使用 PHP 构建此请求。

于 2012-05-26T08:21:33.830 回答