Re: [SOAP] error while passing soap header

[email protected] (Jeffery Fernandez)
Newsgroups php.soap
Organization Internet Vision Technologies
Message-ID <[email protected]>
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
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBHH9TX5WXEviRz51oRAigmAJ9pEk/m6pqasla/BujWzkWr5zul0ACfX9HA
IZeMtydN7xaG6vApEU8hgMs=
=OqGe
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.