Connecting Tech Pros Worldwide Help | Site Map

Error while developing touricoholidays webservice in PHP 5

Newbie
 
Join Date: Oct 2007
Posts: 4
#1: Oct 18 '07
I am wrote the coding for PHP 5 to access tourico holidays webservice. as follows.But it returns the error followed by the code .please help me


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. try{
  3.     class authentication_header 
  4.     {
  5.         private $username;
  6.         private $password;
  7.         private $culture;
  8.         private $version;
  9.  
  10.         public function __construct($username,$password,$culture,$version) 
  11.         {
  12.             $this->username=$username;
  13.             $this->password=$password;
  14.             $this->culture=$culture;
  15.             $this->version=$version;
  16.         }
  17.     }
  18.  
  19.     $wsdl = 'http://demo.touricoholidays.com/ws/HotelsService.asmx?WSDL';                  
  20.     $client = new SOAPClient($wsdl,array('trace'=> true));
  21.  
  22.     $parameter = array('sDestination' => 'NYC',
  23.                       'sHotelCityName' => '',
  24.                       'sHotelLocationName' => '',
  25.                       'sHotelName' => '',
  26.                       'dtCheckIn' => '2007-11-20',
  27.                       'dtCheckOut' => '2007-12-01',
  28.                       'roomsInformation' => $roominfo,
  29.                       'maxPrice' => 0,
  30.                       'starLevel' => 2,
  31.                       'fAvailableOnly' => 1);  
  32.  
  33.     $auth=new authentication_header('yanivy','111111','en_US','5.5');
  34.  
  35.     $authvalues=new SoapVar($auth,SOAP_ENC_OBJECT,'LoginHeader');
  36.  
  37.     $header=new SoapHeader("myURN","LoginHeader",$authvalues,false,"http://schemas.xmlsoap.org/soap/actor/next");
  38.  
  39.     $client->__call('SearchHotels', $parameter, null, $header);
  40. }
  41. catch(SOAPFault $f) 
  42. {
  43.     echo "<pre>";
  44.     print $f;
  45.     echo "</pre>";
  46. }
  47. ?>


Error:
-----------------------------------------------------------------------

SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> TravelService.CustomException.LoginFailedException : Login failed. Check username and password.
at TravelService.BaseAuthService.ValidateLoginHeader( LoginHeader loginHeader, Boolean isCultureMandatory, Boolean isVersionMandatory, Boolean isAmendment)
at TravelService.BaseAuthService.Authenticate(Boolean isCultureMandatory, Boolean isVersionMandatory, Boolean isAmendment)
at TravelService.BaseAuthService.Authenticate()
at TravelService.HotelsService.SearchHotels(String sDestination, String sHotelCityName, String sHotelLocationName, String sHotelName, DateTime dtCheckIn, DateTime dtCheckOut, RoomInfo[] roomsInformation, Decimal maxPrice, Decimal starLevel, Boolean fAvailableOnly)
--- End of inner exception stack trace --- in F:\xampp\htdocs\ico\mydemo2.php:39
Stack trace:
#0 F:\xampp\htdocs\ico\mydemo2.php(39): SoapClient->__call('SearchHotels', Array, NULL, Object(SoapHeader))
#1 {main}
-------------------------------------------------

Please Help me to solve the error
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#2: Oct 18 '07

re: Error while developing touricoholidays webservice in PHP 5


Well, it says you used a bad username/password combination. Check your username and password first, and if those are correct, check the documentation for the web service to ensure that you are properly giving them to the service.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#3: Oct 18 '07

re: Error while developing touricoholidays webservice in PHP 5


Heya, James. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Newbie
 
Join Date: Oct 2007
Posts: 4
#4: Oct 19 '07

re: Error while developing touricoholidays webservice in PHP 5


Quote:

Originally Posted by Motoma

Well, it says you used a bad username/password combination. Check your username and password first, and if those are correct, check the documentation for the web service to ensure that you are properly giving them to the service.


Hai Motoma,

I checked the username and password in PHP 4 it working properly
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#5: Oct 19 '07

re: Error while developing touricoholidays webservice in PHP 5


Quote:

Originally Posted by jamesas

Hai Motoma,

I checked the username and password in PHP 4 it working properly

The web service says otherwise: either you have the wrong username and password, or you have supplied them to the service incorrectly.
Newbie
 
Join Date: Oct 2007
Posts: 4
#6: Oct 25 '07

re: Error while developing touricoholidays webservice in PHP 5


Quote:

Originally Posted by Motoma

The web service says otherwise: either you have the wrong username and password, or you have supplied them to the service incorrectly.

hai,

now im corrected my script and it working properly now
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#7: Oct 25 '07

re: Error while developing touricoholidays webservice in PHP 5


Quote:

Originally Posted by jamesas

hai,

now im corrected my script and it working properly now

Care to elaborate on what the problem was? This will help others who have similar problems and see this thread.
Newbie
 
Join Date: Oct 2007
Posts: 4
#8: Nov 12 '07

re: Error while developing touricoholidays webservice in PHP 5


Quote:

Originally Posted by Motoma

Care to elaborate on what the problem was? This will help others who have similar problems and see this thread.

THIS is the sample header to pass to web service

$client = new SoapClient("http://demo.touricoholidays.com/ws/HotelsService.asmx?WSDL", array("trace" => true, "exceptions" => true, 'soap_version' => SOAP_1_1));

$x["username"]="";
$x["password"]="";
$x["culture"]="en_US";
$x["version"]='4.5';

$header=new SoapHeader('http://tourico.com/webservices/','LoginHeader', $x);

$client->__setSoapHeaders(array($header));
Reply