Re: Re: Instructions for SOAP ws

From: Date: Fri, 30 May 2003 17:30:35 +0000
Subject: Re: Re: Instructions for SOAP ws
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16844@lists.php.net to get a copy of this message
Harry, Thanks a lot for your example, I'm getting this errors: Notice: Undefined index: in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 506 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 Warning: reset(): Passed variable is not an array or object in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 508 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 3 reset () c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:508 Warning: current(): Passed variable is not an array or object in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 509 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 3 current () c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:509 Warning: reset(): Passed variable is not an array or object in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 377 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 3 soap_wsdl->generateproxycode() c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:519 4 reset () c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:377 Warning: current(): Passed variable is not an array or object in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 378 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 3 soap_wsdl->generateproxycode() c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:519 4 current () c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php:378 Fatal error: Cannot instantiate non-existent class: webservice_ in c:\cygwin\home\luigi\tcvs\tiki\lib\pear\SOAP\WSDL.php on line 522 Call Stack # Function Location 1 {main}() c:\cygwin\home\luigi\tcvs\tiki\foo.php:0 2 soap_wsdl->getproxy() c:\cygwin\home\luigi\tcvs\tiki\foo.php:7 ----- Original Message ----- From: "Harry Fuecks" <hfuecks@phppatterns.com> To: <pear-dev@lists.php.net> Sent: Friday, May 30, 2003 12:11 PM Subject: Re: [PEAR-DEV] Re: Instructions for SOAP ws > No problem - hadn't played with it before but here's a simple example that > worked for me. > > hello_server.php; > > <?php > require_once 'SOAP/Server.php'; > > // Your class > class HelloServer { > var $__dispatch_map = array(); > > function HelloServer() { > // Define the signature of the dispatch map > $this->__dispatch_map['sayHello'] = > array('in' => array('inputString' => 'string'), > 'out' => array('outputString' => > 'string'), > ); > } > > // Required function by SOAP_Server > function __dispatch($methodname) { > if (isset($this->__dispatch_map[$methodname])) > return $this->__dispatch_map[$methodname]; > return NULL; > } > > // Your function > function sayHello($inputString) > { > return 'Hello '.$inputString; > } > } > > // Fire up PEAR::SOAP_Server > $server = new SOAP_Server; > > // Fire up your class > $helloServer = new HelloServer(); > > // Add your object to SOAP server (note namespace) > $server->addObjectMap($helloServer,'urn:HelloServer'); > > // Handle SOAP requests coming is as POST data > if (isset($_SERVER['REQUEST_METHOD']) && > $_SERVER['REQUEST_METHOD']=='POST') { > $server->service($HTTP_RAW_POST_DATA); > } else { > // Deal with WSDL / Disco here > require_once 'SOAP/Disco.php'; > > // Create the Disco server > $disco = new SOAP_DISCO_Server($server,'HelloServer'); > header("Content-type: text/xml"); > if (isset($_SERVER['QUERY_STRING']) && > strcasecmp($_SERVER['QUERY_STRING'],'wsdl')==0) { > echo $disco->getWSDL(); // if we're talking > http://www.example.com/index.php?wsdl > } else { > echo $disco->getDISCO(); > } > exit; > } > ?> > > The main thing is getting the dispatch map right. You probably will need to > examine Shane's examples if you're planning to pass structs around - for > simple examples like this believe Shane's leaving it to PHP's reflection to > get right. > > The client for this server; > > hello_client.php > > <?php > require_once 'SOAP/Client.php'; > > $wsdl = new SOAP_WSDL > ('http://localhost/wsdl/hello_server.php?wsdl'); > > $helloClient = $wsdl->getProxy(); > > echo ( $helloClient->sayHello('Luis') ); > ?> > > Hope that helps. BTW - might be worth consider Cache_Lite on the client > side - Cache_Lite_Function would help store the results locally when needed > and reduce network crossings. > > Don't know if you've seen these - may be some more help - I didn't discuss > WSDL on the server side but perhaps some useful info there... > > > http://www.phppatterns.com/index.php/article/articleview/39/1/2/ > (Client) > > http://www.phppatterns.com/index.php/article/articleview/41/1/2/ > (Server) > > http://www.phppatterns.com/index.php/article/articleview/40/1/2/ (Extending > the SOAP_WSDL class) > > > > On Fri, 30 May 2003 09:28:35 -0300, Luis Argerich <luis@fuegolabs.com> > wrote: > > > Well, I'm an idiot, I can't get it to work, I just need the code for a > > server implementing > > a echo_string($msg) method and generating a WSDL that can be reached from > > other apps, > > how is the WSDL accessed? server.php?wsdl as in axis? > > If you or someone know an example of a client/server SOAP ws were the > > server > > also generates it's own WSDL I'd appreciate it. > > If not I'll just wait until someone builds a framework to make this > > usable > > without hours of investigation :-) > > Tks. > > > > ----- Original Message ----- > > From: "Harry Fuecks" <hfuecks@phppatterns.com> > > To: <pear-dev@lists.php.net> > > Sent: Thursday, May 29, 2003 10:09 PM > > Subject: [PEAR-DEV] Re: Instructions for SOAP ws > > > > > >> Hi Luis, > >> > >> Looks your the client is right. > >> > >> Not sure if you've seen these slides; > >> > >> http://talks.php.net/show/soap-phpcon-ny2003/69 > >> http://talks.php.net/show/soap-phpcon-ny2003/70 > >> > >> The SOAP_Disco class is only available with the latest - PEAR::SOAP 0.73 > >> - > >> Shane provides some examples in there - examples/wsdl_client.php talks > >> the > >> server he demonstrates in the slides. There's a another example of WSDL > >> generation on the server side in examples/disco_server.php > >> > >> Hope that helps. > >> > >> On Thu, 29 May 2003 10:03:14 -0300, Luis Argerich <luis@fuegolabs.com> > >> wrote: > >> > >> > Hi, > >> > > >> > I want to implement a WSDL based webservice server & client using PHP. > >> > I've > >> > tried using slides from several PHP talks from Shane but examples > >> don't > >> > work. > >> > Can you point me to a quick working example of a WSDL based client & > >> > server > >> > pls? > >> > (WSDL is needed since the WS will be accessed from other non-php > >> clients > >> > that use the WSDL to access the service) > >> > > >> > Example client: > >> > include("SOAP/Client.php"); > >> > > >> > $wsdl_url = > >> > 'http://localhost/Foo.wsdl'; > >> > $WSDL =& new SOAP_WSDL($wsdl_url); > >> > $soapclient =& $WSDL->getProxy(); > >> > echo $soapclient->echo_string('hey'); > >> > > >> > I just need instructions on how to build the server for this client. > >> > > >> > Thanks in advance. > >> > > >> > > >> > > >> > >> > >> > >> -- > >> PEAR Development Mailing List (http://pear.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > > > > > > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pear.dev (#16844) next »