简体   繁体   English

Apache XML-RPC异常处理

[英]Apache XML-RPC Exception Handling

从Apache的XML-RPC实现返回的异常中提取原始异常的最简单方法是什么?

It turns out that getting the cause exception from the Apache exception is the right one. 事实证明,从Apache异常中获取原因异常是正确的。

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

According to the XML-RPC Spec it returns the "fault" in the xml. 根据XML-RPC Spec,它返回xml中的“fault”。

Is this the "Exception" you are referring to or are you refering to a Java Exception generated while making the XML-RPC call? 这是您所指的“异常”,还是指的是在进行XML-RPC调用时生成的Java异常?

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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM