Loading ...
Sorry, an error occurred while loading the content.

RE: [soaplite] custom fault generates error 500

Expand Messages
  • rafiq.ismail@mail.ing.nl
    RE: [soaplite] custom fault generates error 500 Hi Jens, if ($@) is defined you won t have a result object. You did an eval and thus you ll either have an
    Message 1 of 5 , Jul 1, 2004
    View Source
    • 0 Attachment
      RE: [soaplite] custom fault generates error 500

      Hi Jens,

      if ($@) is defined you won't have a result object.  You did an eval and thus you'll either have an runtime error (invokation of die in this case) caught in $@ or you'll have your return value.

      "perldoc -f eval" might be helpful.

      What you might want is something like:

        my $call=SOAP::Lite->uri('urn:foo')->proxy('http://localhost:3355');

        my $barf = sub { SOAP::Fault->faultcode('foo')->faultstring('bar')->faultdetail('eee');};

        my $res = eval { $call->on_fault( $barf )->method; };

      You should get back an instance of  SOAP::Fault or a response and no error.

      It boils down to your not being able to have it both ways. $@ xor $res.

      I think the document you looked at was more to do with sending the fault from the server side.  I'm not sure whether it is good to trap a transport exception in a soap object either.  If you go back to your previous example, it is better to do the sensible error handing in the if($@){} block and not try to cooerce it into a SOAP::Fault object, which isn't really what I think you're likely to be after.  I usually have something like:

      if ($@ or $res->fault) ....


      R.




      -----Original Message-----
      From:   Jens Puruckherr [mailto:jpuruckherr@...]
      Sent:   Thu 7/1/2004 12:57 PM
      To:     soaplite@yahoogroups.com
      Cc:    
      Subject:        [soaplite] custom fault generates error 500

      Hi,

      my soapserver should generate customized faults as described in
      http://cookbook.soaplite.com/#soap%20faults
      So I have a test-function on the server:

      sub make_fail{
         #generiert SOAP-Fehler
         die SOAP::Fault->faultcode('Server.Custom')
                         ->faultstring('Böser Fehler')
                         ->faultdetail('Aber gewollt!');
      }

      my client:
      -------------------------------------
      [...]
      my $call=SOAP::Lite
         -> uri('urn:simple_o')
         -> proxy ('http://localhost:8081/simple_o ');

      my $res = eval{
         $call->make_fail;
      };

      if($@){
         print STDERR "Fehler bei Ausführung: ".join("\n",$@,'');
         exit;
      }

      if(defined($res)
      [...]
      ---------------------------------------

      My client says:
      Fehler bei Ausführung: 500 Internal Server Error at
      ./simple_client.pl line 36

      The response from the server seems OK:

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server.Custom</faultcode><faultstring>Böser
      Fehler</faultstring><detail xsi:type="xsd:string">Aber
      gewollt!</detail><faultactor>http://localhost:8081/</faultactor></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>


      But there is no result-object ($res) generated.
      Any idea?


         Mit freundlichen Grüßen

            Jens Puruckherr



      Yahoo! Groups Sponsor   
      ADVERTISEMENT
      click here <http://us.ard.yahoo.com/SIG=129tb1ndh/M=295196.4901138.6071305.3001176/D=groups/S=1705701014:HM/EXP=1088765960/A=2128215/R=0/SIG=10se96mf6/*http://companion.yahoo.com>    
       <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=845460659>     

        _____ 

      Yahoo! Groups Links


      *       To visit your group on the web, go to:
              http://groups.yahoo.com/group/soaplite/
               
      *       To unsubscribe from this group, send an email to:
              soaplite-unsubscribe@yahoogroups.com <mailto:soaplite-unsubscribe@yahoogroups.com?subject=Unsubscribe>
               
      *       Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .






      -----------------------------------------------------------------
      ATTENTION:
      The information in this electronic mail message is private and
      confidential, and only intended for the addressee. Should you
      receive this message by mistake, you are hereby notified that
      any disclosure, reproduction, distribution or use of this
      message is strictly prohibited. Please inform the sender by
      reply transmission and delete the message without copying or
      opening it.

      Messages and attachments are scanned for all viruses known.
      If this message contains password-protected attachments, the
      files have NOT been scanned for viruses by the ING mail domain.
      Always scan attachments before opening them.
      -----------------------------------------------------------------
    • Duncan Cameron
      ... Sorry to respond to my own posts ... I can confirm that the ö character does cause a 500 Internal Server Error , and that if the character is removed
      Message 2 of 5 , Jul 1, 2004
      View Source
      • 0 Attachment
        At 2004-07-01, 12:20:28 Duncan Cameron <duncan_cameron2002@...> wrote:

        >At 2004-07-01, 11:57:05 you wrote:
        >
        >>Hi,
        >>
        >>my soapserver should generate customized faults as described in
        >>http://cookbook.soaplite.com/#soap%20faults
        >>So I have a test-function on the server:
        >>
        >>sub make_fail{
        >> #generiert SOAP-Fehler
        >> die SOAP::Fault->faultcode('Server.Custom')
        >> ->faultstring('Böser Fehler')
        >> ->faultdetail('Aber gewollt!');
        >>}
        >>
        >>my client:
        >>-------------------------------------
        >>[...]
        >>my $call=SOAP::Lite
        >> -> uri('urn:simple_o')
        >> -> proxy ('http://localhost:8081/simple_o ');
        >>
        >>my $res = eval{
        >> $call->make_fail;
        >>};
        >>
        >>if($@){
        >> print STDERR "Fehler bei Ausführung: ".join("\n",$@,'');
        >> exit;
        >>}
        >>
        >>if(defined($res)
        >>[...]
        >>---------------------------------------
        >>
        >>My client says:
        >>Fehler bei Ausführung: 500 Internal Server Error at
        >>./simple_client.pl line 36
        >>
        >>The response from the server seems OK:
        >>
        >><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        >>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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server.Custom</faultcode><faultstring>Böser
        >>Fehler</faultstring><detail xsi:type="xsd:string">Aber
        >>gewollt!</detail><faultactor>http://localhost:8081/</faultactor></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
        >>
        >>
        >>But there is no result-object ($res) generated.
        >>Any idea?
        >
        >From your example you appear to be sending back a literal ö character which is not valid
        >UTF-8. This will cause a problem when the SOAP message is parsed which might be causing
        >your problem.
        >Can you try setting your fault strings to be simple ASCII to see whether that removes the
        >problem? If you want to send ISO-8859-1 characters then you need to change the XML
        >declaration using the encoding() method.

        Sorry to respond to my own posts ...

        I can confirm that the ö character does cause a "500 Internal Server Error", and that if the
        character is removed then Jens approach does work, i.e. $@ is false, $res is defined
        and $res->fault contains the fault generated by his server.

        Regards
        Duncan
      • Jens Puruckherr
        ... That s it! Thanks! ... Mit freundlichen Grüßen Jens Puruckherr
        Message 3 of 5 , Jul 1, 2004
        View Source
        • 0 Attachment
          dcameron@... schreibt:
          >
          >From your example you appear to be sending back a literal ö
          >character which is not valid UTF-8. This will cause a problem when
          >the SOAP message is parsed which might be causing your problem.
          >Can you try setting your fault strings to be simple ASCII to see
          >whether that removes the problem? If you want to send ISO-8859-1
          >characters then you need to change the XML declaration using the
          >encoding() method.


          That's it!
          Thanks!
          >

          Mit freundlichen Grüßen

          Jens Puruckherr
        Your message has been successfully submitted and would be delivered to recipients shortly.