Re: [PHP-WEBMASTER] Web Service Problem

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

 



On 15 June 2010 12:44, John <john.zakaria@xxxxxxxxxxxxxx> wrote:
>
>
>
> Really i need help coz i am trying to solve this problem from 4 weeks and i can not so please help me
>
> I want to use a web service ( created in ASP.NEt ) in my web site using php coz i will use the result in other php pages.
> the web service link is: http://196.218.16.133/onlinereservation/service.asmx?WSDL
>
> function name: HotelData  under HotelsSearch
>
> Is there a tool for PHP or any other way to pass string for HotelData    and get an XML file containing the result?
>
>
>
> I tried to learn SOAP  in the manual  and I can not till now return data from this web service
>
>
>
> My Code is:
>
>
>
> <?
>
> header("Content-Type: text/plain");
>
> $client = new SOAPClient('http://196.218.16.133/OnlineReservationTravelline/service.asmx?WSDL');
>
>
>
> try {
>
>           $params->HotelData = '<HotelsParameters><CityID>388</CityID><UserName>admin</UserName><UserPassword>admin</UserPassword><DateFrom>6/12/2010</DateFrom><DateTo>6/13/2010</DateTo><NumberOfRooms>2</NumberOfRooms><Room><RoomSerial>1</RoomSerial><Adults>1</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>5</ChildAge></Child></Room><Room><RoomSerial>2</RoomSerial><Adults>2</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>8</ChildAge></Child><Child><ChildSerial>2</ChildSerial><ChildAge>5</ChildAge></Child></Room><CurrencyID>162</CurrencyID></HotelsParameters>';
>
>
>
>           $result = $client->HotelsSearch($params);
>
>           //echo $result;
>
> } catch (SOAPFault $exception) {
>
>
>
>           print $exception;
>
>           print htmlspecialchars($client->__getLastRequest());
>
> }
>
>
>
> var_dump($result);
>
>
>
> ?>
>
>
>
> Note: the string is ' <HotelsParameters><CityID>388</CityID><UserName>admin</UserName><UserPassword>admin</UserPassword><DateFrom>6/12/2010</DateFrom><DateTo>6/13/2010</DateTo><NumberOfRooms>2</NumberOfRooms><Room><RoomSerial>1</RoomSerial><Adults>1</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>5</ChildAge></Child></Room><Room><RoomSerial>2</RoomSerial><Adults>2</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>8</ChildAge></Child><Child><ChildSerial>2</ChildSerial><ChildAge>5</ChildAge></Child></Room><CurrencyID>162</CurrencyID></HotelsParameters>’
>
>
>
>
>
> John Zakaria Sabry
> Senior Web Developer
>
>
>
> 3 El Nasr Street, EL Nozha EL Gedida,
>  Heliopolis, Cairo, Egypt
>
> Phone: +202 262 00 755 - +2 012 551 5551
>
> Fax: +202 262 00 755
>
> Mobile: +2 018 131 91 89
>
> john.zakaria@xxxxxxxxxxxxxx
>
> www.graphicano.com
>
>

http://pastebin.com/cuXnT9Fb

That contains some PHP classes which are based upon the WSDL file. The
conversion is with the sourceforge wsdl2php project (with some mods).

In YOUR code ...

<?php
// Include the classes which wrap the SOAP service for you.
require_once 'service.php';

try
	{
	// Create a new Service (unforuntate name - maybe ReservationSystem
or something - Service is VERY generic).
	$Service = new Service();

	// Let's do a tour search.
	$TourSearchRequest = new TourSearch();

	// Populate the TourSearchRequest.
	$TourSearchRequest->date = '2010/01/01';

	// Run the search.
	$TourSearchResponse = $Service->TourSearch($TourSearchRequest);

	// Dump the response (expecting it to be of class TourSearchResponse.
	var_dump($TourSearchResponse);
	}

catch(Exception $ex)
	{
	// Dump the exception, taking note of faultstring and faultcode as
these are SOAP Server generated errors.
	var_dump($ex);
	}
?>

But this is generating a SOAP exception on the server, so the client
code won't help here.

["faultstring"]=>string(96) "Server was unable to process request.
---> Object reference not set to an instance of an object."
["faultcode"]=>string(11) "soap:Server"
["detail"]=>string(0) ""

How are you building the WSDL file? By hand? If so, I would recommend
learning about using DocBlocks and a tool to auto generate the WSDL
file.

I use a modified version of Zend's SOAP, WSDL and AutoDiscovery tools
to build my WSDL files from my source code.

I then use a modified sourceforge's wsdl2php project to convert the
wsdl file to normal PHP classes which do all the wrapping of the SOAP
comms for me and let's me use normal PHP coding as if all the services
were local and not on a remote server.

Richard.



--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux