2012-05-26 36 views
3

我正在测试Temando API并尝试创建预订。我遵循了他们的手册Temando API R1_11开发人员指南给出的说明。使用Temando API创建预订

我的问题是,当我使用以下所需信息创建调用makeBookingByRequest: Anythings,Anywhere,Anytime,General,Origin,Destination,Quote,Payment,Instructions,Comments,Comments,Promotion Code。

它返回一个错误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的经验吗?任何帮助,将不胜感激。

+0

错误日志或访问日志中是否有任何消息? – sarnold

+0

我最近检查过,但日志上的错误我们只是我昨晚关于未定义变量的错误。真傻。但除此之外,没有。 – Jetoox

+0

@Jason Sturges你编辑了哪部分? – Jetoox

回答

0

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