Re: SOAP newbie looking for help

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

 



Hi bill,

Thanks for the input.  This prootocol reminds me a bit of OSC, which I've
used before for passing control data for audio applications over networks.

I've found a 'basic' tutorial online that gets one started writing a
'hello world' kind of program with a SOAP server and client, but the
tutorial has problems, the code seems to malfunction.  I'm going to paste
in the files as I found them online, perhaps someone can help me to figure
out what is going wrong.

by the way, the tutorial I'm referring to is at the following URL:
http://evolt.org/article/The_PEAR_SOAP_Implementation/21/49993/index.html

The tutorial says that if I call the client file from my browser, I should
get 'hello world' to show up.  This doesn't happen.  I get some strange
error messages instead, especially after adding the error tracking code
that you suggested (Thanks for that, by the way!).

Here's the errors I get, printed as requested from the client file below:
(apologies for the crappy linebreaks and tabbing)

Printed return from client file:
**********************
Object
message: method '{urn:helloworld}helloWorld' not defined in service
user info: Array
get wire
Here's some user info
stdClass Object (     [file] => /usr/local/php/lib/php/SOAP/Fault.php
[line] => 49     [function] => pear_error     [class] => pear_error
[type] => ::     [args] => Array         (             [0] => method
'{urn:helloworld}helloWorld' not defined in service             [1] =>
Server             [2] =>              [3] =>              [4] =>
)  )

Here's some user info
stdClass Object (     [file] => /usr/local/php/lib/php/SOAP/Base.php
[line] => 199     [function] => soap_fault     [class] => soap_fault
[type] => ->     [args] => Array         (             [0] => method
'{urn:helloworld}helloWorld' not defined in service             [1] =>
Server             [2] =>              [3] =>              [4] =>
[5] =>          )  )

Here's some user info
stdClass Object (     [file] => /usr/local/php/lib/php/SOAP/Server.php
[line] => 377     [function] => _raisesoapfault     [class] => soap_server
[type] => ->     [args] => Array         (             [0] => method
'{urn:helloworld}helloWorld' not defined in service             [1] =>
[2] =>              [3] => Server         )  )

Here's some user info
stdClass Object (     [file] => /usr/local/php/lib/php/SOAP/Server.php
[line] => 168     [function] => parserequest     [class] => soap_server
[type] => ->     [args] => Array         (             [0] =>    World
[1] =>          )  )

Here's some user info
stdClass Object (     [file] =>
/Users/cewing/phpstuff/CMEtests/SOAP/tests/pearsoap-hello-server.php
[line] => 33     [function] => service     [class] => soap_server
[type] => ->     [args] => Array         (             [0] =>    World
)  )
**********************

Client file:

**********************
<?php

require_once("SOAP/Client.php");

$client = new
SOAP_Client('http://trurl.dom.washington.edu/testsite/SOAP/tests/pearsoap-hello-server.php');

$params = array('inmessage'=>'World');
$options = array('trace'=>'true','timeout'=>5);

$response =
$client->call('helloWorld',$params,array('namespace'=>'urn:helloworld'),$options);

print $response.'<br>';

//Stuff added after this point comes from Bill Moran, Thanks!!!!
if (PEAR::isError($response)) {
	echo 'message: '.$response->getMessage().'<br>';
	echo 'user info: '.$response->getUserInfo().'<br>';
	echo 'get wire'.$client->__get_wire().'<br>';
}

foreach ($response->getUserInfo() as $k=>$v) {
	echo "Here's some user info<br>";
	print_r($v);
	echo '<p>';

}

?>
**********************

Server File:

**********************
<?php

require_once('SOAP/Server.php');

class SOAP_Hello_Server {

	var $dispatch_map = array();

	function SOAP_Hello_Server() {

		$this->dispatch_map['helloWorld'] =
array('in'=>array('inmessage'=>'string'),

'out'=>array('outmessage'=>'string'));

	}

	function helloWorld ($inmessage) {

		if ($inmessage == '') {
			$fault = new SOAP_Fault('You must provide a valid
string!','12345');
			return $fault->message();
		} else {
			return "Hello $inmessage!";
		}
	}
}

$server = new SOAP_Server();

$soaphelloserver = new SOAP_Hello_Server();

$server->addObjectMap($soaphelloserver,array('namespace'=>'urn:helloworld'));

$server->service($HTTP_RAW_POST_DATA);

exit;

?>
**********************


********************************
Cris Ewing
CME and Telehealth Web Services
University of Washington
School of Medicine
Work Phone: (206) 685-9116
Home Phone: (206) 365-3413
E-mail: cewing@u.washington.edu
*******************************


On Fri, 27 Feb 2004, Bill Moran wrote:

> cristopher pierson ewing wrote:
> > Hello,
> >
> > I'm building a website to provide online Continuing Medical Education
> > content to Physicians and Helath Care workers.
> >
> > Much of the material for my online courses is being stored in a system
> > called the DigitalWell, created by the University of Washington.  They
> > have provided me with a list of SOAP commands for their front-end API, but
> > I am new to soap and need some help getting started.
> >
> > I have installed the SOAP package (0.83RC3) from the PEAR site and
> > installed it using the pear cli installer.  I can't seem to find any
> > manual or documentation included in the downloaded files, though, and
> > there seems to be no documentation online at PEARs website.
> >
> > I've also tried the FAQ for this list, but find that there are no
> > frequently asked questions yet.
> >
> > Any suggestions of places to look for information on using PEAR::SOAP?
>
> The usage of the soap package is actually so simple that it requires
> almost no documentation!  Of course, you need enough to get you started...
>
> The basic procedure is this:
> $soapobj = new SOAP_Client('http://<URL OF SOAP SERVER>');
> $soapoptions = array('trace' => true, 'timeout' => 5);
> $result = $soapobj->call('<methodname>', $param = array('var1' => $value, 'var2' => $value), $options);
> if (PEAR::isError($result)) {
>   echo $result->getMessage();
>   echo $result->getUserInfo();
>   echo $soapobj->__get_wire();
> }
>
> The options are (by definition) optional.  Setting trace to
> true seems to slow things down a bit, but gives much nicer
> error information when things go wrong (when it's false,
> ->__get_wire() always returns an empty string)  The <methodname>
> and the contents of the $param array will be defined by the stuff
> you got from DigitalWell, as will the format of $result.  If the
> DigitalWell docs are ambiguous, print_r($result) will probably
> help a LOT!
>
> I'm only typing all this out because I don't remember where I
> found the documentation that I used to get started :( and I've
> been unable to find it again!
>
> --
> Bill Moran
> Potential Technologies
> http://www.potentialtech.com
>
> --
> PHP Soap Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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


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

  Powered by Linux