Re: undefined result for fault messages -- resending withou signature

Igor Korolev <[email protected]> Wed, 2 Jul 2003 16:45:33 -0500
Newsgroups gmane.comp.windows.devel.soap.general
Message-ID <F33BD4B0C42B8C4684C24DD28BD4136501053E97@nte2k04.mpls.digitalriver.com>
Jonathan,

My problem is that "method" returns undef when http response code
is not 200, so this is all a beautiful theory which does not work.

Below is a test code and output.  So we see the envelope with
fault, but it is hard to access it.

#!/usr/bin/perl
my $resp;
my $wsurl =  'http://www20.digitalriver.com/rcsdev/macro.wsdl';
 
use SOAP::Lite  +trace => 'debug';
 
$order_id = 12345;
$email = '[email protected]';
$password = 'abcdef';
$store_billing = [ { value=>'MMM', key=>'givenName'}];
$store_shipping = [ {value=>'MMM', key=>'givenName'} ];
 
$profiles = [ {value => $store_billing, key=>'STORE_BILLING' },
              {  value => $store_shipping, key=> 'STORE_SHIPPING'} ];
 
eval
{
  my $svc = SOAP::Lite->service($wsurl);
  $resp =  $svc->placeOrder($order_id, $email,$password, $profiles);
};
die "Got Error: $@" if($@);
print "RESPONSE: [$resp]\n";
my $result = $resp->result();

OUTPUT:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:namesp2="http://xml.apache.org/xml-soap"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:pla
ceOrder xmlns:namesp1="http://digitalriver.store"><orderID
xsi:type="xsd:string">12345</orderID><email
xsi:type="xsd:string">[email protected]</email><password
xsi:type="xsd:string">abcdef</password><profiles
SOAP-ENC:arrayType="namesp2:SOAPStruct[2]"
xsi:type="apachesoap:Map"><item xsi:type="namesp2:SOAPStruct"><value
SOAP-ENC:arrayType="namesp2:SOAPStruct[1]"
xsi:type="SOAP-ENC:Array"><item xsi:type="namesp2:SOAPStruct"><value
xsi:type="xsd:string">MMM</value><key
xsi:type="xsd:string">givenName</key></item></value><key
xsi:type="xsd:string">STORE_BILLING</key></item><ite!
m xsi:type="namesp2:SOAPStruct"><value
SOAP-ENC:arrayType="namesp2:SOAPStruct[1]"
xsi:type="SOAP-ENC:Array"><item xsi:type="namesp2:SOAPStruct"><value
xsi:type="xsd:string">MMM</value><key
xsi:type="xsd:string">givenName</key></item></value><key
xsi:type="xsd:string">STORE_SHIPPING</key></item></profiles></namesp1:pl
aceOrder></SOAP-ENV:Body></SOAP-ENV:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal
Server Error
Cache-Control: no-cache="set-cookie,set-cookie2"
Connection: close
Date: Wed, 02 Jul 2003 21:29:40 GMT
Server: JRun Web Server
Content-Language: en-US
Content-Type: text/xml; charset=utf-8
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Client-Date: Wed, 02 Jul 2003 21:31:36 GMT
Client-Peer: 10.114.0.45:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Set-Cookie: CFID=5318;domain=.macromedia.com;expires=Fri, 24-Jun-2033
20:58:40 GMT;path=/
Set-Cookie:
CFTOKEN=d64b0e2e96d79a54-24EBB07C-AF53-E066-8F570C5078A9F72B;domain=.mac
romedia.com;expires=Fri, 24-Jun-2033 20:58:40 GMT;path=/
Set-Cookie: JSESSIONID=96302836891057181380733;path=/
Set-Cookie:
UID=24EBB097%2DE220%2DE4D7%2D5D886211B6C6CA4C;domain=.macromedia.com;exp
ires=Fri, 24-Jun-2033 20:58:40 GMT;path=/cfusion/

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.generalException</faultcode>
   <faultstring>[org.apache.axis.AxisFault : ; nested exception is: 
        org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object;
-&gt; interface java.util.Map)]; nested exception is: 
        coldfusion.xml.rpc.CFCInvocationException:
[org.apache.axis.AxisFault : ; nested exception is: 
        org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object;
-&gt; interface java.util.Map)]</faultstring>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>

RESPONSE: []
Can't call method "result" on an undefined value at ./ex888.pl line 23.


-----Original Message-----
From: jpeyser [mailto:[email protected]]
Sent: Wednesday, July 02, 2003 2:54 PM
To: Igor Korolev
Subject: Re: undefined result for fault messages


Igor,

   Unless I misunderstand you, it seems straight forward. See the 
SOAP::SOM description in the SOAP::Lite MAN page. For the XML below, 
you would retrieve the fields as follows.

$som = $soap->method(@parameters);

if ($som->fault) { 
    if ($som->match('/Envelope/Body/Fault/Code/')) {
        print $som->valueof('Value'), "\n";
        print $som->valueof('Subcode/Value'), "\n";
    }
    if ($som->match('/Envelope/Body/Fault/Reason/')) {
        print $som->valueof('Text'), "\n";
        print $som->valueof('Text'), "\n";
    }
    if ($som->match('/Envelope/Body/Fault/Detail/')) {
        print $som->valueof('myFaultDetails/message'), "\n";
        print $som->valueof('myFaultDetails/errorcode'), "\n";
    }
}

Jonathan


--- In [email protected], "Igor Korolev" <IgorK@D...> wrote:
> Hello,
> 
> Could somebody please tell me if there are methods for getting fault
> text received in SOAP body of a
> response ?
> 
> For some reason, SOAP::Lite::call will not return anything if HTTP
> response code is not 200 while current SOAP standard
> http://www.w3.org/TR/2003/REC-soap12-part0-20030624/
> says that
> 
> If an error occurs processing the request, the HTTP binding
> specification requires that a HTTP 500 "Internal Server Error" be 
used
> with an embedded SOAP message containing a SOAP fault indicating the
> server-side processing error.
> Example 11 is the same SOAP fault message as Example 6a, but this 
time
> with the HTTP headers added.
> 
> Example 11 
> HTTP/1.1 500 Internal Server Error
> Content-Type: application/soap+xml; charset="utf-8"
> Content-Length: nnnn
> 
> <?xml version='1.0' ?>
> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
>   <env:Body>
>     <env:Fault>
>      <env:Code>
>        <env:Value>env:Sender</env:Value>
>        <env:Subcode>
>         <env:Value>rpc:BadArguments</env:Value>
>        </env:Subcode>
>      </env:Code>
>      <env:Reason>
>       <env:Text xml:lang="en-US">Processing error</env:Text>
>       <env:Text xml:lang="cs">Chyba zpracovani</env:Text>
>      </env:Reason>
>      <env:Detail>
>       <e:myFaultDetails 
>         xmlns:e="http://travelcompany.example.org/faults" >
>         <e:message>Name does not match card number</e:message>
>         <e:errorcode>999</e:errorcode>
>       </e:myFaultDetails>
>      </env:Detail>
>    </env:Fault>
>  </env:Body>
> </env:Envelope>
> 
> Thank you,
> 
> Igor Korolev