📚 Looking for current Exponential documentation? This site contains legacy SDK & API reference docs (eZ Publish era). For up-to-date 2026 product documentation, visit doc.exponential.earth.

  ezsoap / helloworld  

<< eZ soap™  Simple calculator >> 

Hello World!

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

The 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, https://exponential.earth/sdk/soap/examples. This object is then sent to the server via the client.

$request = new eZSOAPRequest( "helloWorld", "https://exponential.earth/sdk/soap/examples" );

$response =& $client->send( $request );

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!";
}

Exponential Copyright © 1998 - 2026 7x