Re: Query with pear SOAP and SOAP_Fault
| From: | Justin Patrin | Date: | Mon, 19 Jul 2004 15:57:27 +0000 |
| Subject: | Re: Query with pear SOAP and SOAP_Fault | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13752@lists.php.net to get a copy of this message | ||
On Mon, 19 Jul 2004 15:47:41 +0100, Chris Covell <chris.covell@gmail.com> wrote:
> Hello guys,
>
> I have a query with pear soap and SOAP_Fault, I wonder if anyone has
> an answer...
>
> As a bit of background, I am using pear SOAP 0.8RC3 beta under php-4.3.4-1.1.
>
> I have a soap server process that works fine ! I have got a client
> that connects to it fine also. I have adopted the technique of using
> the dispatch_map so that a wsdl is created automagically:
>
> $this->__dispatch_map['request'] =
> array( 'in' => array('input' => 'string'),
> 'out' => array('return string' =>
> 'string'),
> );
>
> As you can see I have defined in and out parameters as strings.
>
> Now, I have a customer connecting to this server using a Java client.
> He has built his client based on my wsdl. He wants me to return errors
> as soap faults. I am doing it like this:
>
> $fault = new SOAP_Fault('Does not exist', '99');
> return $fault->message();
You may as well not be creating that SOAP_Fault. All you're doing is
extracting your message as a string and returning that. This code is
equivalent:
return 'Does not exist';
You should be doing:
return new SOAP_Fault('Does not exist', '99');
AFAIK, you don't have to declare this in your WSDL, it's assumed that
any SOAP call that fails will return a SOAP_Fault.
>
> The trouble is that he is seeing the SOAP fault data, but it is
> wrapped up in a string, this is what he describes:
>
> "In case of error I expect your service to return something like this:
>
> <http>
> <soap:fault/>
> </http>
>
> But actually your service is returning something like this:
>
> <http>
> <soap:return>
> <soap:fault/gt&;
> </soap:return>
> </http>
>
> The SOAP Fault is actually "masked" inside a normal result. In my
> opinion you have do make a little change in your WSDL to define the
> possible returned faults."
>
> So my question is:
>
> How do I return a soap fault in the way he describes ? Can I define a
> "fault" out in my dispatch map -> wsdl ?
>
> Hopefully you can help me !
>
> Chris...
>
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--