Path

ez.no / exponential / documentation / development / libraries / ez soap / hello world example


Hello World example

These documentation pages are no longer maintained. Please visit the new documentation site.

Every SDK with programming examples must contain a hello world example, eZ soap is no exception. This example shows how you can send a request to a SOAP server and print out the result.

Talking with the server

he default transport in eZ soap is HTTP. In this example we set up a client object to talk to the server myserver.com and the path /helloworld.

include_once( "lib/ezsoap/classes/ezsoapclient.php" );

include_once( "lib/ezsoap/classes/ezsoaprequest.php" );

 

$client = new eZSOAPClient( "myserver.com", "/helloworld" );

Sending a request

You need to prepare a request object to send. In this example we have a simple request without any parameters. All we need to do is to give the request name, helloWorld, and the target namespace, http://ez.no/sdk/soap/examples. This object is then sent to the server via the client.

Response

When the request is sent you will get a response returned from the server. This response will be returned by eZ soap as a eZSOAPResponse object. If the server returned a fault the faultcode and faultstring is printed. If all was successful the response value from the server is printed.

As you can see the values returned from the server is automatically converted to PHP types, all the encoding/decoding of data is handled by the eZ soap library.

if ( $response->isFault() )

{

   print( "SOAP fault: " . $response->faultCode(). " - " . $response->faultString() . "" );

}

else

   print( "Returned SOAP value was: \"" . $response->value() . "\"" );

The server

To create a SOAP server is just as simple as the client. All you need to do is to create an eZSOAPServer object. Then you need to register the functions which should be available. These functions are normal PHP functions returning normal PHP variables, eZ soap? handles the rest. To process the incoming request you run the function processRequest().

include_once( "lib/ezsoap/classes/ezsoapserver.php" );

 

$server = new eZSOAPServer();

 

$server->registerFunction( "helloWorld" );

 

$server->processRequest();

 

function helloWorld()

{

   return "Hello World!";

}

Comments

log in or create a user account to comment.

Contents

Development

Extensions
Exponential datamodel
Exponential tuning and stability
Importing attribute data
Kernel
Libraries
    eZ xml
    eZ db
    eZ i18n
    eZ soap
       Consuming web services with eZ SOAP C...
       Hello World example
       Hello World example ( Exponential 3.5 + )
    eZ template
    eZ webdav
Scripting
Standards
System overview
Test Suite
Using Doxygen to create API documenta...


Created

04/07/2003
10:50:18 am
by Bård Farstad

Last updated

04/07/2003
10:50:18 am
by Bård Farstad

Authors

Bård Farstad



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.