By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,603 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,603 IT Pros & Developers. It's quick & easy.

PEAR::SOAP - Server returns only "Object" as answer

P: n/a
Hi !

I am new to Web Services. Therefore I ve set up a PHP Installation on Windows
(PHP 4.3.2 and Apache 1.3.29). I have tested PHP alone and then installed
PEAR. Now I am stuck there (Before that, I had many problems with the

I've set up several SOAP Testscripts that I found on WebSites and in PHP-Books
to get a PHP Client and a PHP Server communicate over Web Services
(using PEAR::SOAP).

Here is my major-problem located, My Helly World example produces no errors,
But instead of returning "Hello World" as answer, it only returns "Object", It
makes no diffence, what I want to submit, there s only the answer "Object" and
this makes me sick and sleepless, because I run out of time (i have to do this
for an university-exam)

I guess, there is something wrong with the installation, so PEAR might fail in
parsing the XML document, or so. If there any professionals out there who
ever worked with PEAR::SOAP and might know that problem, please help, i ll
need that. :(
Thanx in advance !




Example Code :




/* Create a new SOAP client using PEAR::SOAP's SOAP_Client-class: */
$client = new SOAP_Client('http://localhost/pearsoap-hello-server.php');
/* Define the parameters we want to send to the server's helloWorld-function.
Note that these arguments should be sent as an array: */
$params = array('inmessage'=>'World');

/* Send a request to the server, and store its response in $response: */
$response = $client->call('helloWorld',$params,array('namespace' =>

/* Print the server-response: */
print $response;




/* Include PEAR::SOAP's SOAP_Server class: */
/* To define a new SOAP service with PEAR::SOAP, we need to
construct a class that defines the characteristics for our
service. An instance of this class is then used by SOAP_Server
to create a new SOAP service: */
class SOAP_Hello_Server

/* $dispatch_map helps SOAP_Server figure out which parameters
are used with the methods: */
var $dispatch_map = array();

/* dispatch mapping is optional. It is used in non-wsdl servers to allow
for being more explicit with what arguments and types are passed in and
/* Here's the constructor for out class. It is used to define
$dispath_map: */
function SOAP_Hello_Server()
$this->dispatch_map['helloWorld'] = array('in' =>
'out' =>

/* Of course, we also need to define all the functions that should
be requestable through our server: */
function helloWorld($inmessage)
/* Generate a SOAP error if the argument was not valid: */
if($inmessage == '')
/* The SOAP error is generated by the SOAP_Fault class: */
$fault = new SOAP_Fault('You must supply a valid
return $fault->message();
/* If the argument is okay, we submit out return message: */
return "Hello $inmessage!";

/* Create a new SOAP server using PEAR::SOAP's SOAP_Server class: */
$server = new SOAP_Server();

/* Create an instance of our class: */
$soaphelloserver = new SOAP_Hello_Server();

/* Register this instance to the server class: */
$server->addObjectMap($soaphelloserver,array('namespace' =>

/* The following line starts the actual service: */

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.