Returning Soap_Fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I've got a SOAP server using PEAR::SOAP (latest) and a client using PHP
5.1.4 bundled SOAP. I could eventually use PEAR::SOAP on the client as
well but I seem to have issues with the server so it's not an issue at
the moment.

I'm trying hard to return a proper SOAP_Fault from the server but even
after googling all around I haven't found how to do it.

Obviously I'm trying to return a SOAP_Fault from reverseMessage() method
in the code below. While playing with this code I got all different
kinds of results, from "Violation of encoding rules" to httpd crashes. I
even tried to throw a regular exception in reverseMessage() and have
try {
	$server->service(...);
}
catch (Exception $ex) {
	$server->_raiseSoapFault(...);
}
but that wouldn't work either.

Any hints are highly appreciated.

This is my simple server.php:

<?php
require_once('SOAP/Server.php');
require_once('SOAP/Disco.php');

class TestFault {
        var $__dispatch_map = array();
        function TestFault() {
                $this->__dispatch_map['reverseMessage'] = array(
                        "in"  => array("message" => "string"),
                        "out" => array("result" => "string"),
                );
        }
        function reverseMessage($message)
        {
#                return new Soap_Fault("Exxeption:$message:", 123);
                return strrev($message);
        }
}

$server = new SOAP_Server();
$webservice = new TestFault();
$server->addObjectMap($webservice,
	'http://schemas.xmlsoap.org/soap/envelope/');

if (isset($_SERVER['REQUEST_METHOD']) &&
	$_SERVER['REQUEST_METHOD']=='POST')
		$server->service($HTTP_RAW_POST_DATA);
?>

The client is even simpler:
<?php
$client = new SoapClient($wsdl_url, array('trace' => 1));
$result = $client->reverseMessage("Test Message");
if (is_soap_fault($result)) {
     trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, ".
                   "faultstring: {$result->faultstring})",
                   E_ERROR);
        }
print_r($result);
echo("\nDone.");
?>

Thanks

Michal Ludvig

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux