3

What is the easiest way to extract the original exception from an exception returned via Apache's implementation of XML-RPC?

2
  • What is the context of this question? Are you using XML-RPC directly? Commented Sep 9, 2008 at 21:44
  • I'm using Apache's implementation, namely ws.apache.org/xmlrpc Commented Sep 11, 2008 at 14:04

2 Answers 2

4

It turns out that getting the cause exception from the Apache exception is the right one.

} catch (XmlRpcException rpce) {
    Throwable cause = rpce.getCause();
    if(cause != null) {
        if(cause instanceof ExceptionYouCanHandleException) {
            handler(cause);
        }
        else { throw(cause); }
    }
    else { throw(rpce); }
}
Sign up to request clarification or add additional context in comments.

Comments

1

According to the XML-RPC Spec it returns the "fault" in the xml.

Is this the "Exception" you are referring to or are you refering to a Java Exception generated while making the XML-RPC call?

Fault example

HTTP/1.1 200 OK
Connection: close
Content-Length: 426
Content-Type: text/xml
Date: Fri, 17 Jul 1998 19:55:02 GMT
Server: UserLand Frontier/5.1.2-WinNT

<?xml version="1.0"?>
<methodResponse>
  <fault>
    <value>
      <struct>
      <member>
        <name>faultCode</name>
        <value><int>4</int></value>
      </member>
      <member>
        <name>faultString</name>
        <value>
          <string>Too many parameters.</string>
        </value>
      </member>
      </struct>
    </value>
  </fault>
</methodResponse> 

1 Comment

Let's say basic authentication is used... how do you get the header to be HTTP/1.1 401 Unauthorized rather?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.