connecting to webservice Using PHP & Soap
ok I'm trying to connect to a webservice which utilizes the OTA XML schema ("http://www.opentravel.org/OTA/2003/05/GetVehAvailRate")
this webservice is hosted at rentcentric.com, which is a hosted solution for taking reservations and bookings online, the system requires a username and password to connect & so far every attempt at connecting has resulted in a blank white page.
no error messages no PHP output,
Im still fairly new to using SOAP, (although I did have great success when using it on an estate agents site - which didnt require any authentication just a simple value to identify the company on that service)
I have read and tried nearly all the examples found on this site & others with no joy!
the request made to the service is outlined below, each request has a core set of arguments which are:
PickUpDateTime //date
ReturnDateTime //date
PickUpLocation.locationCode //string
ReturnLocation.locationCode //string
PromotionCod //string
the service url http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx has all the methods available to us.
# GetVehAvailRate
# VehCancel
# VehLocSearch
# VehModify
# VehRes
Request -: GetVehAvailRate
<?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://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<SRVCredentials xmlns="http://www.opentravel.org/OTA/2003/05">
<Username>*USERNAME*</Username>
<Password>*PASSWORD*</Password>
</SRVCredentials>
</soap:Header>
<soap:Body>
<OTA_VehAvailRateRQ EchoToken="string" TimeStamp="dateTime" Target="Test or Production" Version="decimal" TransactionIdentifier="string" SequenceNmbr="nonNegativeInteger" TransactionStatusCode="Start开发者_JAVA百科 or End or Rollback or InSeries or Continuation or Subsequent" PrimaryLangID="language" AltLangID="language" RetransmissionIndicator="boolean" ReqRespVersion="string" MaxResponses="positiveInteger" MaxPerVendorInd="boolean" xmlns="http://www.opentravel.org/OTA/2003/05">
<POS>............
code example:
$soapClient = new SoapClient("http://www2.rentcentric.com/Ota2007a/OTASrvc.asmx?wsdl");
// Prepare SoapHeader parameters
$sh_param = array(
'Username'=>'username',
'Password'=>'password');
$headers = new SoapHeader('http://www2.rentcentric.com/Ota2007a/', 'UserCredentials', $sh_param);
// Prepare Soap Client
$soapClient->__setSoapHeaders(array($headers));
Im just bangning my head against the wall trying to get something to return, All I need is pointed in the right direction...
Look at the documentation here:
http://www.php.net/manual/en/soapclient.soapclient.php
to see how to add the trace variable to your SoapClient constructor. Once you've done that you can use
- SoapClient::__getLastRequestHeaders
- SoapClient::__getLastRequest
- SoapClient::__getLastResponse
- SoapClient::__getLastResponseHeaders
As a means to, at the very least, get some feedback as to why your calls are failing.
You can try using another soap implementation and see if the problem persists. I suggest you Zend Soap
精彩评论