Re: error while passing soap header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 25 October 2007 00:49, Jamesas wrote:
>         error_reporting(E_ALL);
>         
>         $ini = ini_set("soap.wsdl_cache_enabled","0");
>
>         //set up the service client using WSDL

<!-- SNIP -->

You hade the namespace for the SoapHeader set wrong. Here is a working version:

<?php

error_reporting(E_ALL);
$ini = ini_set("soap.wsdl_cache_enabled","0");


try {
	//set up the service client using WSDL
	echo "Connecting to server using WSDL<br />";
	
	$client = new SoapClient("http://demo.touricoholidays.com/ws/HotelsService.asmx?WSDL";, array("trace" => true, "exceptions" => true, 'soap_version' => SOAP_1_1));
	
	
	//var_dump($client->__getFunctions());
	//var_dump($client->__getTypes());
	
	$x["username"]="ofstays";
	$x["password"]="111111";
	$x["culture"]="en_US";
	$x["version"]='4.5';
	
	//$x = new SoapVar($x, SOAP_ENC_OBJECT, "AuthenticationHeader","http://www.itworks.nl/";);
	$header=new SoapHeader('http://tourico.com/webservices/','LoginHeader', $x);
	
	$client->__setSoapHeaders(array($header));
	echo "SoapHeaders set sucessfully<br />";
	
	
	//$roominfo = array('AdultsNum' => 1,'ChildNum' => 1,'ChildAges' => 8);
	$parameter = array(
		'sDestination' => 'NYC',
		'sHotelCityName' => '',
		'sHotelLocationName' => '',
		'sHotelName' => '',
		'dtCheckIn' => '2007-11-20',
		'dtCheckOut' => '2007-12-01',
		'roomsInformation' => array('RoomInfo' => array('AdultsNum' => 1, 'ChildNum' => 1, 'ChildAges' => array('ChildAge' => 8))),
		'maxPrice' => 0,
		'starLevel' => 2,
		'fAvailableOnly' => 1
	);
	
	//$result2 = $client->__soapCall('Hello',$params2, NULL,$header,$output_headers);
	
	$result = $client->SearchHotels($parameter);
	
	
	echo("<br />REQUEST :<br />" . htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .htmlspecialchars($client->__getLastResponse()) . "<br />");
}
catch (SoapFault $ex)
{
	echo "Error:<br />" . nl2br($ex->faultcode) . '<br /><br />Error Details:<br />'. nl2br($ex->faultstring) . '<br />';
	
	echo("<br />REQUEST :<br />" . htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .htmlspecialchars($client->__getLastResponse()) . "<br />");	
}

?>


cheers,
Jeffery
-- 
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia

Attachment: pgpFLK2UU69lu.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux