Apache XML-RPC Exception Handling

What is the easiest way to catch the original exception from the exception returned using the Apache XML-RPC implementation?

+3
source share
2 answers

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

} catch (XmlRpcException rpce) {
    Throwable cause = rpce.getCause();
    if(cause != null) {
        if(cause instanceof ExceptionYouCanHandleException) {
            handler(cause);
        }
        else { throw(cause); }
    }
    else { throw(rpce); }
}
+4
source

According to the XML-RPC Spec, it returns an "error" in xml.

Is this the “Exception” you are referring to, or is it referring to the Java exception thrown when you call the XML-RPC?

Error 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
source

Source: https://habr.com/ru/post/1696749/


All Articles