PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SoapServer->setClass()> <SoapServer->getFunctions()
Last updated: Fri, 18 Jul 2008

view this page in

SoapServer->handle()

(PHP 5 >= 5.0.1)

SoapServer->handle() — Handles a SOAP request

Description

SoapServer
void handle ([ string $soap_request ] )

Processes a SOAP request, calls necessary functions, and sends a response back.

Parameters

soap_request

The SOAP request. If this argument is omitted, the request is supposed to be in the $HTTP_RAW_POST_DATA PHP variable.

Return Values

No value is returned.

Examples

Example #1 Some examples

<?php
function test($x)
{
    return 
$x;
}

$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>



add a note add a note User Contributed Notes
SoapServer->handle()
Blizzke at gmail dot com
12-Mar-2008 05:39
Seems pretty logical once you find the solution, but it took me quite a while to figure this one out:
If you are using WSDL based SOAP requests and you have more than one operation in your binding (with the same parameters), make sure the <soap:operation> style is set to rpc, NOT body!

When you specify 'body' here, all that will be transmitted in the request is the parameters for the function call, and SoapServer->handle() will use the first function it finds with the same parameter-makeup to handle the call.

ie If you have 2 functions:
<?php
function One ( string $blah );
function
Two ( string $blah );
?>
Making a client call with SoapClient -> Two ( 'test' ); will result in One ( ) being called when your 'type' is set to 'body'

The actual method to call will only be included in the request when your type is set to 'rpc', resulting in the expected behavior
king dot maxemilian at noos dot fr
21-Aug-2007 09:23
Sometime, it happens that PHP does not detect anything in $HTTP_RAW_POST_DATA.

To solve this problem and make it work in any case:

function soaputils_autoFindSoapRequest()    {
    global $HTTP_RAW_POST_DATA;
   
    if($HTTP_RAW_POST_DATA)
        return $HTTP_RAW_POST_DATA;
   
    $f = file("php://input");
    return implode(" ", $f);
}

$server = new SoapServer($wsdl);
$server->setClass($MyClass);

$server->handle(soaputils_autoFindSoapRequest());

SoapServer->setClass()> <SoapServer->getFunctions()
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites