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

catching SOAP faults

Expand Messages
  • Chris
    I have a Java axis webservice I am trying to call from perl. Everything works fine as long as the proper things are passed and everything is okay. However, I
    Message 1 of 3 , Aug 9 5:49 PM
    • 0 Attachment
      I have a Java axis webservice I am trying to call from perl.
      Everything works fine as long as the proper things are passed and
      everything is okay. However, I have a method, that takes an array of
      elements which needs to be event. If it is not, the method returns a
      SOAPFAULTException which should produce a soap fault. The method
      does not return any arguments so there is not return value (it returns
      a undef in perl just to make sure). But if I pass it an odd # of
      aruments, the method just silently returns nothing and it goes on.
      If I turn trace on, I can see that the method actually fails with
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal
      Server Error

      and then I see the return fault from the service:
      <?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.userException</faultcode>
      <faultstring>javax.xml.rpc.soap.SOAPFaultException: create_event
      failed: Arguments must be key value pairs, not an even number of
      arguments</faultstring>
      <detail/>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>
      SOAP::Transport::HTTP::Client::send_receive: POST
      http://localhost:8080/pes_webservice/services/ProductionEventService
      Accept: text/xml
      Accept: multipart/*
      Content-Length: 688
      Content-Type: text/xml; charset=utf-8
      SOAPAction: ""

      In addition, if the webserver return any fault to any method, it is
      quietly ignored. How can I get back the faults in perl SOAP::Lite?
      Since the return value is undef, I cannot look at $ret->fault, or
      anyting like that?

      Thanks
      Chris
    • Duncan Cameron
      ... That us exactly what you do look at. my $som = $soap- some_method(); if ($som- fault) { print $som- faultcode; } else { # it worked print $som- result; }
      Message 2 of 3 , Aug 10 12:42 PM
      • 0 Attachment
        On 2005-08-10 at 00:49:33 Chris wrote:

        > I have a Java axis webservice I am trying to call from perl.
        >Everything works fine as long as the proper things are passed and
        >everything is okay. However, I have a method, that takes an array of
        >elements which needs to be event. If it is not, the method returns a
        >SOAPFAULTException which should produce a soap fault. The method
        >does not return any arguments so there is not return value (it returns
        >a undef in perl just to make sure). But if I pass it an odd # of
        >aruments, the method just silently returns nothing and it goes on.
        >If I turn trace on, I can see that the method actually fails with
        >SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal
        >Server Error
        >
        >and then I see the return fault from the service:
        ><?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.userException</faultcode>
        > <faultstring>javax.xml.rpc.soap.SOAPFaultException: create_event
        >failed: Arguments must be key value pairs, not an even number of
        >arguments</faultstring>
        > <detail/>
        > </soapenv:Fault>
        > </soapenv:Body>
        ></soapenv:Envelope>
        >SOAP::Transport::HTTP::Client::send_receive: POST
        >http://localhost:8080/pes_webservice/services/ProductionEventService
        >Accept: text/xml
        >Accept: multipart/*
        >Content-Length: 688
        >Content-Type: text/xml; charset=utf-8
        >SOAPAction: ""
        >
        >In addition, if the webserver return any fault to any method, it is
        >quietly ignored. How can I get back the faults in perl SOAP::Lite?
        >Since the return value is undef, I cannot look at $ret->fault, or
        >anyting like that?

        That us exactly what you do look at.

        my $som = $soap->some_method();

        if ($som->fault) {
        print $som->faultcode;
        } else {
        # it worked
        print $som->result;
        }

        Regards

        Duncan Cameron
      • Duncan Cameron
        ... Are you using a WSDL file? If so then you get the SOM object by $soap- call; Otherwise, you shouldn t be getting an undefined value back from your call.
        Message 3 of 3 , Aug 11 6:27 AM
        • 0 Attachment
          --- Christopher Mihaly <cmihaly@...> wrote:

          > That is what I tried, however $som is undef and I get a perl
          > dereference
          > error if I try to get to $som->fault. Is there something I need to
          > set to
          > get it to return these codes?
          >
          > Chris
          >

          Are you using a WSDL file? If so then you get the SOM object by

          $soap->call;

          Otherwise, you shouldn't be getting an undefined value back from your
          call. Can you post the part of your code that is doing the remote call?

          Duncan




          ___________________________________________________________
          To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
        Your message has been successfully submitted and would be delivered to recipients shortly.