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

does it make sense to give no return value?

Expand Messages
  • Tilman Baumann
    Hi, i have a funktion at the serverside wich adds an element to a database. This funktion has a appropriate errorhandling with die s. (Throwing exceptions with
    Message 1 of 4 , Dec 8, 2003
    View Source
    • 0 Attachment
      Hi,

      i have a funktion at the serverside wich adds an element to a database.
      This funktion has a appropriate errorhandling with die's. (Throwing
      exceptions with die seens to be a nice idea to generate a soapfault)

      I think it would not make any sense to give any return value in this
      funktion because if anything goes wrong i get a fault and if not all is
      perfect.

      Is that the right thinking? What is the common way? Is it supposed to do
      this in this way?

      I get a empty <s-gensym3 xsi:type="xsd:string"/> back. That looks a bit
      strange. :) (soapreturn below)

      Thank you for answer.

      Date: Mon, 08 Dec 2003 10:24:25 GMT.
      Server: libwww-perl-daemon/1.25.
      Content-Length: 545.
      Content-Type: text/xml; charset=utf-8.
      SOAPServer: SOAP::Lite/Perl/0.55.
      .
      <?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
      >
      <namesp1:addResponse xmlns:namesp1="http://www.ben-hur.de/Updateserver"
      >
      <s-gensym3
      xsi:type="xsd:string"/></namesp1:addResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
      --
      Tilman Baumann

      pyramid computer GmbH
      Boetzinger Strasse 60 D-79111 Freiburg

      ----------------------------------
      They who would give up an essential liberty for temporary security, deserve
      neither liberty or security
      - Benjamin Franklin
    • Jens Puruckherr
      ... I have replaced every die() with my die_with_fault(). So can I return my own fault-massage to the client. The client and his logs now know exactly what ist
      Message 2 of 4 , Dec 8, 2003
      View Source
      • 0 Attachment
        Tilman Baumann <Tilman.Baumann@...> writes:
        >
        >Is that the right thinking? What is the common way? Is it supposed
        >to do
        >this in this way?
        >
        >I get a empty <s-gensym3 xsi:type="xsd:string"/> back. That looks a
        >bit
        >strange. :) (soapreturn below)

        I have replaced every die() with my die_with_fault(). So can I return
        my own fault-massage to the client.
        The client and his logs now know exactly what ist happen.

        #############################################################################
        sub die_with_fault {
        #############################################################################
        my ($self,$code,$string,$detail) = @_;

        use SOAP::Lite;
        # Generiert eine Schöne Faultmessage für Soap
        die SOAP::Fault->faultcode($code) # will be qualified
        ->faultstring($string)
        ->faultdetail($detail);
        }
        >
        >

        Mit freundlichen Grüßen

        Jens Puruckherr
      • Tilman Baumann
        Nice. Now i can give really sensefull faultmessages. But im allready not sure what i have to return on success. Well i can return a string true or success
        Message 3 of 4 , Dec 8, 2003
        View Source
        • 0 Attachment
          Nice. Now i can give really sensefull faultmessages.

          But im allready not sure what i have to return on success. Well i can
          return a string 'true' or 'success' but is this the common way?

          Jens Puruckherr wrote:
          > Tilman Baumann <Tilman.Baumann@...> writes:
          >
          >>Is that the right thinking? What is the common way? Is it supposed
          >>to do
          >>this in this way?
          >>
          >>I get a empty <s-gensym3 xsi:type="xsd:string"/> back. That looks a
          >>bit
          >>strange. :) (soapreturn below)
          >
          >
          > I have replaced every die() with my die_with_fault(). So can I return
          > my own fault-massage to the client.
          > The client and his logs now know exactly what ist happen.
          >
          > #############################################################################
          > sub die_with_fault {
          > #############################################################################
          > my ($self,$code,$string,$detail) = @_;
          >
          > use SOAP::Lite;
          > # Generiert eine Schöne Faultmessage für Soap
          > die SOAP::Fault->faultcode($code) # will be qualified
          > ->faultstring($string)
          > ->faultdetail($detail);
          > }
          >
          >>
          >
          > Mit freundlichen Grüßen
          >
          > Jens Puruckherr
          >
          >


          --
          Tilman Baumann

          pyramid computer GmbH
          Boetzinger Strasse 60 D-79111 Freiburg

          ----------------------------------
          They who would give up an essential liberty for temporary security, deserve
          neither liberty or security
          - Benjamin Franklin
        • Jens Puruckherr
          ... If your applikation returns true then the status of your SOAP-Call will be 200 OK if you use http-transport. If you return a value, you can use it via
          Message 4 of 4 , Dec 9, 2003
          View Source
          • 0 Attachment
            Tilman Baumann <Tilman.Baumann@...> writes:
            >Nice. Now i can give really sensefull faultmessages.
            >
            >But im allready not sure what i have to return on success. Well i
            >can
            >return a string 'true' or 'success' but is this the common way?

            If your applikation returns 'true' then the status of your SOAP-Call
            will be "200 OK" if you use http-transport.
            If you return a value, you can use it via the result() method.

            my $server = SOAP::Lite
            ->uri ..
            ->proxy .. ;
            my $result = $server->method(param);

            print $server->transport->status; # gives you the status i.e. "200 OK"
            print $result->result; # prints you the returnvalue from your
            application

            # prints the fault-info
            if($res->fault){
            print $result->faultcode;
            print $result->faultstring;
            print $result ->faultdetail;
            }


            >
            >

            Mit freundlichen Grüßen

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