ZF-1364: Zend_XmlRpc_Client forces faultCode and faultString on response


The faultCode/faultString in the response should be optional and not considered mandatory.

For example from Java a standard exception has no code what so ever, hence, the field faultCode in the response is empty, which leads to a Zend_XmlRpc_Client_Exception.


Assigning to Matthew.

Just to give feedback, if this is mandatory indeed (I found and read the" rel="nofollow">spec in the meantime and it's not so clear on this) this may be a week implementation in the Java-based XML-RPC service I have to query. What would be your advice then?

Can you give an example fault response payload that triggers the exception? Zend_XmlRpc_Fault::loadXml() only throws exceptions for the following conditions:

  • malformed XML
  • malformed fault response, which means that it doesn't minimally have structure
  • BOTH code AND message missing from the fault struct

In the case of a missing code, it simply sets it to '404', and uses the message provided. My inclination is that the response you're getting back is so far different from a typical XML-RPC response as to be unrecognizable.

Apologies for the delay - this is what I get when I dump:

$httpResponse = $http->request(Zend_Http_Client::POST);


<?xml version="1.0"?>
faultStringjava.lang.ClassCastException: java.lang.IntegerfaultCode0

Exception: Fault code and string required

The problem is with the XML, in particular, the faultString value; it's missing the tag indicating the value type. Instead of:

java.lang.ClassCastException: java.lang.Integer

it should be reading:

java.lang.ClassCastException: java.lang.Integer

The only way to fix this is to intercept the XML as it arrives and insert the tag (can be done using either regexp, DOM, or SimpleXML).

Fault response returned from third-party server does not conform to XML-RPC spec; not an issue of ZF.

The XML-RPC spec states that if no type supplied, "string" is assumed. So this fault is not so far away from the standard. ;-)…

Zend_XmlRpc_Value is correctly defaulting to using strings if no type is provided; however, Zend_XmlRpc_Fault is not using Zend_XmlRpc_Value to pull the fault struct.

Resolved in r5279.