0

Hi All,

I need to create a couple of webservices, where I retrieve info from the database.

Found this example on php.net while searching for examples:

class MyClass {
   public function helloWorld() {

     return 'Hallo Welt '. print_r(func_get_args(), true);
   }
 }

 try {
   $server = new SOAPServer(
     NULL,
     array(
      'uri' => 'http://localhost/soap/server.php'
     )
   );

   $server->setClass('MyClass');
   $server->handle();
 }

 catch (SOAPFault $f) {
   print $f->faultstring;
 }

?>

 // client.php:

<?php
 $client = new SoapClient(null, array(
       'location' => "http://localhost/soap/server.php",
       'uri'      => "http://localhost/soap/server.php",
       'trace'    => 1 ));

 echo $return = $client->__soapCall("helloWorld",array("world"));

I can see the logic here - And am wondering if oit is that simple..? Dont I need to create a WSDL file for this to work?

Is it correct understood that PHP has a function which creates the WSDL file automatically?

So for starters, is the above sufficient to get me going?

/Klemme

2
Contributors
1
Reply
13
Views
3 Years
Discussion Span
Last Post by pritaeas
0

And am wondering if oit is that simple..?

It should be, but it's been a while since I've used SOAPServer with PHP.

Dont I need to create a WSDL file for this to work?

A WSDL is needed when you want to publicly expose your API. Since you are writing both, it may not be necessary.

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.