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

RE: [soaplite] Quick question -- Simple Fault handling

Expand Messages
  • Mitchell, Louise M
    if ($response- fault) { die $response- faultstring; } else { my $result = $response- result; return $result; #my %result = %{$response- result}; #print
    Message 1 of 7 , Jun 4, 2004
    • 0 Attachment
      if ($response->fault)
      {
      die $response->faultstring;
      }
      else
      {
      my $result = $response->result;
      return $result;
      #my %result = %{$response->result};
      #print map("$_: @{[$result{$_} || '']}\n", keys %result), "\n";
      }

      -----Original Message-----
      From: chenlyc7 [mailto:chenl@...]
      Sent: Friday, June 04, 2004 11:08 AM
      To: soaplite@yahoogroups.com
      Subject: [soaplite] Quick question -- Simple Fault handling


      Hi,
      I'm trying to get our perl client to handle a very simple Fault
      message from the server that has the following format:


      <?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>A sample fault message here...</faultstring>
      <detail>
      <string>A sample fault message here...</string>
      </detail>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>

      how would one be able to retrieve the strings in faultstring and detail
      tags if the hypothetical client had the following code:

      $soap_response= SOAP::Lite
      -> uri('<URI of the service>')
      -> proxy('http://address_here')
      -> methodName(SOAP::Data->name(arg0 => \@arg0stuff),
      SOAP::Data->name(arg1 => \@arg1stuff), SOAP::Data->name(arg2
      =>\@arg2stuff))
      -> result;

      ? I am new to this and would like to quickly setup an example for perl
      to handle simple faults as described above.

      Thanks in advance!





      Yahoo! Groups Links
    • YU Fan
      A simpler way: $soap_response= SOAP::Lite - uri( ) - proxy( http://address_here ) - methodName() - result - on_fault(sub { my($soap,
      Message 2 of 7 , Jun 5, 2004
      • 0 Attachment
        A simpler way:

        $soap_response= SOAP::Lite
        -> uri('<URI of the service>')
        -> proxy('http://address_here')
        -> methodName()
        -> result
        -> on_fault(sub { my($soap, $res) = @_;
        die ref $res ? $res->faultstring :
        $soap->transport->status, "\n";
        });


        -Yu


        --- "Mitchell, Louise M" <Louise.Mitchell@...>
        wrote:
        > if ($response->fault)
        > {
        > die $response->faultstring;
        > }
        > else
        > {
        > my $result = $response->result;
        > return $result;
        > #my %result = %{$response->result};
        > #print map("$_: @{[$result{$_} || '']}\n", keys
        > %result), "\n";
        > }
        >
        > -----Original Message-----
        > From: chenlyc7 [mailto:chenl@...]
        > Sent: Friday, June 04, 2004 11:08 AM
        > To: soaplite@yahoogroups.com
        > Subject: [soaplite] Quick question -- Simple Fault
        > handling
        >
        >
        > Hi,
        > I'm trying to get our perl client to handle a
        > very simple Fault
        > message from the server that has the following
        > format:
        >
        >
        > <?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>A sample fault message
        > here...</faultstring>
        > <detail>
        > <string>A sample fault message here...</string>
        > </detail>
        > </soapenv:Fault>
        > </soapenv:Body>
        > </soapenv:Envelope>
        >
        > how would one be able to retrieve the strings in
        > faultstring and detail
        > tags if the hypothetical client had the following
        > code:
        >
        > $soap_response= SOAP::Lite
        > -> uri('<URI of the service>')
        > -> proxy('http://address_here')
        > -> methodName(SOAP::Data->name(arg0 =>
        > \@arg0stuff),
        > SOAP::Data->name(arg1 => \@arg1stuff),
        > SOAP::Data->name(arg2
        > =>\@arg2stuff))
        > -> result;
        >
        > ? I am new to this and would like to quickly setup
        > an example for perl
        > to handle simple faults as described above.
        >
        > Thanks in advance!
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >





        __________________________________
        Do you Yahoo!?
        Friends. Fun. Try the all-new Yahoo! Messenger.
        http://messenger.yahoo.com/
      • Chen, Li Ye (Research)
        Hmm...I ve tried the code below as well, but it turns out that the compiler does t like it: Can t call method on_fault on unblessed reference at
        Message 3 of 7 , Jun 7, 2004
        • 0 Attachment
          Hmm...I've tried the code below as well, but it turns out that the compiler
          does't like it:

          "Can't call method "on_fault" on unblessed reference at perl_client_fault.pl
          line
          19."

          Is on_fault an actual method under SOAP::Lite module?

          Thanks!

          -----Original Message-----
          From: YU Fan [mailto:fanyu_ca@...]
          Sent: Saturday, June 05, 2004 9:24 PM
          To: Mitchell, Louise M; chenlyc7; soaplite@yahoogroups.com
          Subject: RE: [soaplite] Quick question -- Simple Fault handling


          A simpler way:

          $soap_response= SOAP::Lite
          -> uri('<URI of the service>')
          -> proxy('http://address_here')
          -> methodName()
          -> result
          -> on_fault(sub { my($soap, $res) = @_;
          die ref $res ? $res->faultstring :
          $soap->transport->status, "\n";
          });


          -Yu


          --- "Mitchell, Louise M" <Louise.Mitchell@...>
          wrote:
          > if ($response->fault)
          > {
          > die $response->faultstring;
          > }
          > else
          > {
          > my $result = $response->result;
          > return $result;
          > #my %result = %{$response->result};
          > #print map("$_: @{[$result{$_} || '']}\n", keys
          > %result), "\n";
          > }
          >
          > -----Original Message-----
          > From: chenlyc7 [mailto:chenl@...]
          > Sent: Friday, June 04, 2004 11:08 AM
          > To: soaplite@yahoogroups.com
          > Subject: [soaplite] Quick question -- Simple Fault
          > handling
          >
          >
          > Hi,
          > I'm trying to get our perl client to handle a
          > very simple Fault
          > message from the server that has the following
          > format:
          >
          >
          > <?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>A sample fault message
          > here...</faultstring>
          > <detail>
          > <string>A sample fault message here...</string>
          > </detail>
          > </soapenv:Fault>
          > </soapenv:Body>
          > </soapenv:Envelope>
          >
          > how would one be able to retrieve the strings in
          > faultstring and detail
          > tags if the hypothetical client had the following
          > code:
          >
          > $soap_response= SOAP::Lite
          > -> uri('<URI of the service>')
          > -> proxy('http://address_here')
          > -> methodName(SOAP::Data->name(arg0 =>
          > \@arg0stuff),
          > SOAP::Data->name(arg1 => \@arg1stuff),
          > SOAP::Data->name(arg2
          > =>\@arg2stuff))
          > -> result;
          >
          > ? I am new to this and would like to quickly setup
          > an example for perl
          > to handle simple faults as described above.
          >
          > Thanks in advance!
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          >





          __________________________________
          Do you Yahoo!?
          Friends. Fun. Try the all-new Yahoo! Messenger.
          http://messenger.yahoo.com/
        • YU Fan
          According to sopalite.com: By default client will die with diagnostic on transport errors and do nothing for faulted calls, so, you ll be able to get fault
          Message 4 of 7 , Jun 7, 2004
          • 0 Attachment
            According to sopalite.com: By default client will die
            with diagnostic on transport errors and do nothing for
            faulted calls, so, you'll be able to get fault info
            from result. You can alter this behavior with
            on_fault() handler either per object (will die on both
            transport errors and SOAP faults).

            You may want to check
            http://guide.soaplite.com/#error%20handling for detail
            on "on_fault" and its different usages.

            -Yu

            --- "Chen, Li Ye (Research)" <chenl@...>
            wrote:
            > Hmm...I've tried the code below as well, but it
            > turns out that the compiler
            > does't like it:
            >
            > "Can't call method "on_fault" on unblessed reference
            > at perl_client_fault.pl
            > line
            > 19."
            >
            > Is on_fault an actual method under SOAP::Lite
            > module?
            >
            > Thanks!
            >
            > -----Original Message-----
            > From: YU Fan [mailto:fanyu_ca@...]
            > Sent: Saturday, June 05, 2004 9:24 PM
            > To: Mitchell, Louise M; chenlyc7;
            > soaplite@yahoogroups.com
            > Subject: RE: [soaplite] Quick question -- Simple
            > Fault handling
            >
            >
            > A simpler way:
            >
            > $soap_response= SOAP::Lite
            > -> uri('<URI of the service>')
            > -> proxy('http://address_here')
            > -> methodName()
            > -> result
            > -> on_fault(sub { my($soap, $res) = @_;
            > die ref $res ? $res->faultstring :
            > $soap->transport->status, "\n";
            > });
            >
            >
            > -Yu
            >
            >
            > --- "Mitchell, Louise M" <Louise.Mitchell@...>
            > wrote:
            > > if ($response->fault)
            > > {
            > > die $response->faultstring;
            > > }
            > > else
            > > {
            > > my $result = $response->result;
            > > return $result;
            > > #my %result = %{$response->result};
            > > #print map("$_: @{[$result{$_} || '']}\n",
            > keys
            > > %result), "\n";
            > > }
            > >
            > > -----Original Message-----
            > > From: chenlyc7 [mailto:chenl@...]
            > > Sent: Friday, June 04, 2004 11:08 AM
            > > To: soaplite@yahoogroups.com
            > > Subject: [soaplite] Quick question -- Simple Fault
            > > handling
            > >
            > >
            > > Hi,
            > > I'm trying to get our perl client to handle a
            > > very simple Fault
            > > message from the server that has the following
            > > format:
            > >
            > >
            > > <?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>A sample fault message
            > > here...</faultstring>
            > > <detail>
            > > <string>A sample fault message
            > here...</string>
            > > </detail>
            > > </soapenv:Fault>
            > > </soapenv:Body>
            > > </soapenv:Envelope>
            > >
            > > how would one be able to retrieve the strings in
            > > faultstring and detail
            > > tags if the hypothetical client had the following
            > > code:
            > >
            > > $soap_response= SOAP::Lite
            > > -> uri('<URI of the service>')
            > > -> proxy('http://address_here')
            > > -> methodName(SOAP::Data->name(arg0 =>
            > > \@arg0stuff),
            > > SOAP::Data->name(arg1 => \@arg1stuff),
            > > SOAP::Data->name(arg2
            > > =>\@arg2stuff))
            > > -> result;
            > >
            > > ? I am new to this and would like to quickly setup
            > > an example for perl
            > > to handle simple faults as described above.
            > >
            > > Thanks in advance!
            > >
            > >
            > >
            > >
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > >
            > >
            > >
            >
            >
            >
            >
            >
            > __________________________________
            > Do you Yahoo!?
            > Friends. Fun. Try the all-new Yahoo! Messenger.
            > http://messenger.yahoo.com/
            >





            __________________________________
            Do you Yahoo!?
            Friends. Fun. Try the all-new Yahoo! Messenger.
            http://messenger.yahoo.com/
          • Paul Kulchenko
            ... - on_fault(sub { my($soap, $res) = @_; die ref $res ? $res- faultstring : $soap- transport- status, n ; }) ... ; Paul.
            Message 5 of 7 , Jun 7, 2004
            • 0 Attachment
              on_fault should be called BEFORE ->result():

              > $soap_response= SOAP::Lite
              > -> uri('<URI of the service>')
              > -> proxy('http://address_here')
              -> on_fault(sub { my($soap, $res) = @_;
              die ref $res ? $res->faultstring :
              $soap->transport->status, "\n";
              })
              > -> methodName()
              > -> result
              ;

              Paul.

              --- "Chen, Li Ye (Research)" <chenl@...> wrote:
              > Hmm...I've tried the code below as well, but it turns out that the
              > compiler
              > does't like it:
              >
              > "Can't call method "on_fault" on unblessed reference at
              > perl_client_fault.pl
              > line
              > 19."
              >
              > Is on_fault an actual method under SOAP::Lite module?
              >
              > Thanks!
              >
              > -----Original Message-----
              > From: YU Fan [mailto:fanyu_ca@...]
              > Sent: Saturday, June 05, 2004 9:24 PM
              > To: Mitchell, Louise M; chenlyc7; soaplite@yahoogroups.com
              > Subject: RE: [soaplite] Quick question -- Simple Fault handling
              >
              >
              > A simpler way:
              >
              > $soap_response= SOAP::Lite
              > -> uri('<URI of the service>')
              > -> proxy('http://address_here')
              > -> methodName()
              > -> result
              > -> on_fault(sub { my($soap, $res) = @_;
              > die ref $res ? $res->faultstring :
              > $soap->transport->status, "\n";
              > });
              >
              >
              > -Yu
              >
              >
              > --- "Mitchell, Louise M" <Louise.Mitchell@...>
              > wrote:
              > > if ($response->fault)
              > > {
              > > die $response->faultstring;
              > > }
              > > else
              > > {
              > > my $result = $response->result;
              > > return $result;
              > > #my %result = %{$response->result};
              > > #print map("$_: @{[$result{$_} || '']}\n", keys
              > > %result), "\n";
              > > }
              > >
              > > -----Original Message-----
              > > From: chenlyc7 [mailto:chenl@...]
              > > Sent: Friday, June 04, 2004 11:08 AM
              > > To: soaplite@yahoogroups.com
              > > Subject: [soaplite] Quick question -- Simple Fault
              > > handling
              > >
              > >
              > > Hi,
              > > I'm trying to get our perl client to handle a
              > > very simple Fault
              > > message from the server that has the following
              > > format:
              > >
              > >
              > > <?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>A sample fault message
              > > here...</faultstring>
              > > <detail>
              > > <string>A sample fault message here...</string>
              > > </detail>
              > > </soapenv:Fault>
              > > </soapenv:Body>
              > > </soapenv:Envelope>
              > >
              > > how would one be able to retrieve the strings in
              > > faultstring and detail
              > > tags if the hypothetical client had the following
              > > code:
              > >
              > > $soap_response= SOAP::Lite
              > > -> uri('<URI of the service>')
              > > -> proxy('http://address_here')
              > > -> methodName(SOAP::Data->name(arg0 =>
              > > \@arg0stuff),
              > > SOAP::Data->name(arg1 => \@arg1stuff),
              > > SOAP::Data->name(arg2
              > > =>\@arg2stuff))
              > > -> result;
              > >
              > > ? I am new to this and would like to quickly setup
              > > an example for perl
              > > to handle simple faults as described above.
              > >
              > > Thanks in advance!
              > >
              > >
              > >
              > >
              > >
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > >
              > >
              > >
              >
              >
              >
              >
              >
              > __________________________________
              > Do you Yahoo!?
              > Friends. Fun. Try the all-new Yahoo! Messenger.
              > http://messenger.yahoo.com/
              >
              >
              > ------------------------ Yahoo! Groups Sponsor
              > --------------------~-->
              > Yahoo! Domains - Claim yours for only $14.70
              > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/W6uqlB/TM
              >
              --------------------------------------------------------------------~->
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
            • Chen, Li Ye (Research)
              Thanks Paul! That works. :-) ... From: Paul Kulchenko [mailto:paulclinger@yahoo.com] Sent: Monday, June 07, 2004 3:26 PM To: Chen, Li Ye (Research); YU Fan ;
              Message 6 of 7 , Jun 9, 2004
              • 0 Attachment
                Thanks Paul! That works. :-)

                -----Original Message-----
                From: Paul Kulchenko [mailto:paulclinger@...]
                Sent: Monday, June 07, 2004 3:26 PM
                To: Chen, Li Ye (Research); 'YU Fan'; Mitchell, Louise M;
                soaplite@yahoogroups.com
                Subject: RE: [soaplite] Quick question -- Simple Fault handling



                on_fault should be called BEFORE ->result():

                > $soap_response= SOAP::Lite
                > -> uri('<URI of the service>')
                > -> proxy('http://address_here')
                -> on_fault(sub { my($soap, $res) = @_;
                die ref $res ? $res->faultstring :
                $soap->transport->status, "\n";
                })
                > -> methodName()
                > -> result
                ;

                Paul.

                --- "Chen, Li Ye (Research)" <chenl@...> wrote:
                > Hmm...I've tried the code below as well, but it turns out that the
                > compiler
                > does't like it:
                >
                > "Can't call method "on_fault" on unblessed reference at
                > perl_client_fault.pl
                > line
                > 19."
                >
                > Is on_fault an actual method under SOAP::Lite module?
                >
                > Thanks!
                >
                > -----Original Message-----
                > From: YU Fan [mailto:fanyu_ca@...]
                > Sent: Saturday, June 05, 2004 9:24 PM
                > To: Mitchell, Louise M; chenlyc7; soaplite@yahoogroups.com
                > Subject: RE: [soaplite] Quick question -- Simple Fault handling
                >
                >
                > A simpler way:
                >
                > $soap_response= SOAP::Lite
                > -> uri('<URI of the service>')
                > -> proxy('http://address_here')
                > -> methodName()
                > -> result
                > -> on_fault(sub { my($soap, $res) = @_;
                > die ref $res ? $res->faultstring :
                > $soap->transport->status, "\n";
                > });
                >
                >
                > -Yu
                >
                >
                > --- "Mitchell, Louise M" <Louise.Mitchell@...>
                > wrote:
                > > if ($response->fault)
                > > {
                > > die $response->faultstring;
                > > }
                > > else
                > > {
                > > my $result = $response->result;
                > > return $result;
                > > #my %result = %{$response->result};
                > > #print map("$_: @{[$result{$_} || '']}\n", keys
                > > %result), "\n";
                > > }
                > >
                > > -----Original Message-----
                > > From: chenlyc7 [mailto:chenl@...]
                > > Sent: Friday, June 04, 2004 11:08 AM
                > > To: soaplite@yahoogroups.com
                > > Subject: [soaplite] Quick question -- Simple Fault
                > > handling
                > >
                > >
                > > Hi,
                > > I'm trying to get our perl client to handle a
                > > very simple Fault
                > > message from the server that has the following
                > > format:
                > >
                > >
                > > <?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>A sample fault message
                > > here...</faultstring>
                > > <detail>
                > > <string>A sample fault message here...</string>
                > > </detail>
                > > </soapenv:Fault>
                > > </soapenv:Body>
                > > </soapenv:Envelope>
                > >
                > > how would one be able to retrieve the strings in
                > > faultstring and detail
                > > tags if the hypothetical client had the following
                > > code:
                > >
                > > $soap_response= SOAP::Lite
                > > -> uri('<URI of the service>')
                > > -> proxy('http://address_here')
                > > -> methodName(SOAP::Data->name(arg0 =>
                > > \@arg0stuff),
                > > SOAP::Data->name(arg1 => \@arg1stuff),
                > > SOAP::Data->name(arg2
                > > =>\@arg2stuff))
                > > -> result;
                > >
                > > ? I am new to this and would like to quickly setup
                > > an example for perl
                > > to handle simple faults as described above.
                > >
                > > Thanks in advance!
                > >
                > >
                > >
                > >
                > >
                > > Yahoo! Groups Links
                > >
                > >
                > >
                > >
                > >
                > >
                >
                >
                >
                >
                >
                > __________________________________
                > Do you Yahoo!?
                > Friends. Fun. Try the all-new Yahoo! Messenger.
                > http://messenger.yahoo.com/
                >
                >
                > ------------------------ Yahoo! Groups Sponsor
                > --------------------~-->
                > Yahoo! Domains - Claim yours for only $14.70
                > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/W6uqlB/TM
                >
                --------------------------------------------------------------------~->
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.