notices and transforms them
into XML SOAP Fault Response MEssages which are sent back to the client.
You can even decide which Error Messages are taken from the Exception based
on the Exception type with $server->registerException() // or something
like that.
greetings,
Benjamin
On Wed, 11 Mar 2009 17:56:10 -0700 (PDT), James Gordon
<jamesg@cryptopia.com.au> wrote:
>
> I have a class called Foo that is exposed as a Web Service using
> Zend_Soap_Server, in the usual way, eg:
>
> $server = new Zend_Soap_Server(APPLICATION_PATH . '/foo/wsdl');
> $server->setClass('Foo');
> $server->handle();
>
> On normal execution, any method of the Foo class that is called by SOAP
> clients runs successfully and the appropriate XML document is returned to
> the client courtesy of Zend_Soap_Server.
>
> My question, however, is this: What is the best approach to handling
> abnormal execution? Eg. the client supplies an invalid parameter when
> calling one of Foo's methods via SOAP?
>
> As I understand it, the correct behaviour in this situation is for the
> SOAP
> server to send back a document to the client detailing the fault. The two
> key fields in this document are faultcode and faultstring.
>
> The only solution I've found so far that achieves this is to have Foo's
> methods throw SoapFault() exceptions when they encounter problems.
> However,
> I'm not fond of this approach because:
>
> 1. This means Foo has knowledge about how it is being exposed to the
> outside
> world (SOAP), which, ideally, it should not have, both for idealistic OO
> design reasons and practical testing reasons.
>
> 2. Throwing a generic Exception doesn't work because the faultcode and
> faultstring don't get passed back to the client.
>
> 3. Throwing a Zend_Soap_Server_Exception doesn't work either, because it
> simply inherits from Zend_Exception, which inherits from Exception, so
the
> behaviour is identical to the previous point.
>
> BTW - I should point out that I'm using Zend Framework 1.7.6.
>
> If anybody has any words of wisdom they could offer on this topic, I
would
> be most grateful.
> --
> View this message in context:
>
http://www.nabble.com/Zend-SOAP-server%3A-what-is-the-best-approach-for-error-exception-handling--tp22467835p22467835.html
> Sent from the Zend Web Services mailing list archive at Nabble.com.
没有评论:
发表评论