Re: SOAP newbie looking for help

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

 



See below ...

cristopher pierson ewing wrote:
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);

try like this:


$client->call('helloWorld',$params,$options);

Not sure where 'urn:helloworld' is supposed to go, but I think it should work without
it.

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;

?>

-- 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


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

  Powered by Linux