Cook Computing

XML-RPC Error Reporting

October 30, 2002 Written by Charles Cook

I've received a couple of emails recently about problems with XML-RPC.NET which turned out to be problems with the XML-RPC services being used. As it happens I've been doing some work on improving error reporting which will improve diagnosis of problems like these, but with the main focus being on reporting errors in response or request parsing. Where complex data structures consisting of nested arrays and structs are used - and some of the structures people are using are very complex indeed - it can be difficult to work out why the response or request fails to map onto the .NET types used in the proxy or server implementation. The changes involve dumping the state of the parse stack when an error occurs along with a description of the error.

For example, this morning I wrote some code to call the NewsIsFree service. The structure for each news item contains a date member, described as "the timestamp at which the news item was added to the database". So I defined this structure to represent a news item, using a DateTime type because I expected the date member in the response to be a dateTime.iso8601 value:

struct NewsItem
    public string title;
    public string link;
    public DateTime date;

I made a call, using the latest dev build of XML-RPC.NET, to the hpe.getSource method and received an exception containing this message:

response contains int value where dateTime expected [response : struct mapped to type Source : member items mapped to type NewsItem[] : array mapped to type NewsItem[] : element 0 : struct mapped to type NewsItem : member date mapped to type DateTime]

This provides enough information to determine that the date member is actually returned as an integer.

Note: in case anyone else is affected, the services currently with problems are:

Advogato: diary.getDates returns an invalid XML-RPC response

NewsIsFree: hpe.getSources returns an empty HTTP response