Connecting to webservice Using PHP & Soap

ok I'm trying to connect to a web service that uses the OTA XML Schema (" http://www.opentravel.org/OTA/2003/05/GetVehAvailRate ")

this web service is hosted on rentcentric.com, which is a hosted online booking solution. Connecting to the system requires a username and password, and so far every attempt to connect has led to a blank white page.

no error messages without PHP output,

I'm still pretty new to using SOAP (although I had great success using it on a real estate agents website for which didnt require any authentication just to identify the company in this service)

I read and tried almost all the examples found on this site, and others without joy!

the request specified in the service is described below, each request has a basic set of arguments, which:

PickUpDateTime //date ReturnDateTime //date PickUpLocation.locationCode //string ReturnLocation.locationCode //string PromotionCod //string 

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 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)); 

I just nail my head against the wall, trying to get something back, Everything I need is pointed in the right direction ...

+4
source share
2 answers

Check out the documentation here:

http://www.php.net/manual/en/soapclient.soapclient.php

to see how to add a trace variable to your SoapClient constructor. Once you do, you can use

  • SoapClient :: __ getLastRequestHeaders
  • SoapClient :: __ getLastRequest
  • SoapClient :: __ getLastResponse
  • SoapClient :: __ getLastResponseHeaders

As a means to at least get some feedback on why your calls fail.

+2
source

You can try using a different soap implementation and see if the problem goes away. I suggest you Zend Soap

0
source

Source: https://habr.com/ru/post/1343155/


All Articles