You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-auto@ws.apache.org by "Juha Syrjälä (JIRA)" <xm...@ws.apache.org> on 2006/09/15 10:13:23 UTC

[jira] Commented: (XMLRPC-113) faultCode and faultString not working when throwing XmlRpcException on server

    [ http://issues.apache.org/jira/browse/XMLRPC-113?page=comments#action_12434906 ] 
            
Juha Syrjälä commented on XMLRPC-113:
-------------------------------------

I believe that the bug is in class org.apache.xmlrpc.server.ReflectiveXmlRpcHandler, in method invoke()

It is currenlty (in version 3.0) following:

    private Object invoke(Object pInstance, Method pMethod, Object[] pArgs) throws XmlRpcException {
        try {
	        return pMethod.invoke(pInstance, pArgs);
	    } catch (IllegalAccessException e) {
	        throw new XmlRpcException("Illegal access to method "
	                                  + pMethod.getName() + " in class "
	                                  + clazz.getName(), e);
	    } catch (IllegalArgumentException e) {
	        throw new XmlRpcException("Illegal argument for method "
	                                  + pMethod.getName() + " in class "
	                                  + clazz.getName(), e);
	    } catch (InvocationTargetException e) {
	        Throwable t = e.getTargetException();
	        throw new XmlRpcException("Failed to invoke method "
	                                  + pMethod.getName() + " in class "
	                                  + clazz.getName() + ": "
	                                  + t.getMessage(), t);
	    }
	}

The last catch should be:

	    } catch (InvocationTargetException e) {
	        Throwable t = e.getTargetException();
          if(t instanceof XmlRpcException) {
            throw (XmlRpcException)t;
          }
	        throw new XmlRpcException("Failed to invoke method "
	                                  + pMethod.getName() + " in class "
	                                  + clazz.getName() + ": "
	                                  + t.getMessage(), t);
	    }

> faultCode and faultString not working when throwing XmlRpcException on server
> -----------------------------------------------------------------------------
>
>                 Key: XMLRPC-113
>                 URL: http://issues.apache.org/jira/browse/XMLRPC-113
>             Project: XML-RPC
>          Issue Type: Bug
>          Components: Releases
>    Affects Versions: 3.0
>         Environment: Tomcat
>            Reporter: Juha Syrjälä
>
> I am trying to create fault message with specific faultCode and faultString, but so far I have had little success.
> I am using XML-RPC libs from file xmlrpc-3.0-bin.tar.gz
> The method I am using on server is this:
>   public Map method(Map request) throws XmlRpcException {
>     throw new XmlRpcException(301, "My error message");
>   }
> This should generate fault message with faultCode=301 and faultString="My error message".
> However, this XML is what server sends over network. Notice that faultCode is 0 and not 301, and faultString has additional text appended before "My error message".
> <?xml version="1.0" encoding="UTF-8"?>
> <methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
> <fault>
> <value>
> <struct>
> <member>
> <name>faultString</name>
> <value>Failed to invoke method method in class MyXmlRpcClass: My error message</value>
> </member>
> <member>
> <name>faultCode</name>
> <value><i4>0</i4></value>
> </member>
> </struct>
> </value>
> </fault>
> </methodResponse>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira