Re: Fault Strings

Scott Hutton <[email protected]> Sun, 28 Apr 2002 11:28:56 -0700 (PDT)
Newsgroups gmane.comp.gnome.ximian.soup
Message-ID <[email protected]>
On Apr 22, Alex Graveley wrote:
| On Mon, 2002-04-22 at 14:41, Scott Hutton wrote:
| > On Apr 21, Alex Graveley wrote:
| > | SOUP_MESSAGE_IS_ERROR only tells you if the HTTP response was
| > | unsuccessful, not whether a successful response contains a SOAP fault.
| > 
| > So, what's the proper way to obtain the fault string/code, etc.?
| > 
| >  -Scott
| 
| if (SOUP_MESSAGE_IS_ERROR(msg)) {
| 	g_print ("SOUP Error: %d \"%s\"\n", 
| 		 msg->errorcode,
| 		 msg->errorphase);
| 	exit (1);
| }
| 
| parser = soup_parser_new_from_buffer (&msg->response);
| 
| fault = soup_parser_get_fault (parser);
| if (fault) {
| 	g_print ("SOAP Fault: %s\n", soup_fault_get_string (fault));
| 	exit (1);
| }
| 
| ... process successful message ...

I think we've tracked this down.  There are a couple of problems.
If you're wondering why I didn't attach a diff, read on...

Problem #1 is that Soup only considers 2xx HTTP responses to
be valid SOAP replies (SOUP_ERROR_CLASS_SUCCESS), and 5xx to be
SOUP_ERROR_CLASS_SERVER_ERROR.

That'd be all well 'n good, if SOAP faults weren't 500's (as per the
spec -- see http://www.w3.org/TR/SOAP/, section 6.2).  Personally,
I think this was a bad decision on the part of the spec writers, but
SOAP::Lite faithfully honors it.

So, the code that checks for SOUP_MESSAGE_IS_ERROR ignores faults all
together.

However, this isn't enough to fix the problem.  Simply redefining Soup's
errcodes doesn't coax it into finding the fault.  The problem appears
to be in soup-parser.c's get_params_from_node().

There's a check for

  if (!strcmp(tmp->name, "Fault")) {

However, with a bit of debugging, you'll see that the parent of that
node is the one with a name of "Fault".  That should be:

  if (!strcmp(xml_node->name, "Fault")) {

to detect the fault data.

Further down, another correction needs to be made in the call to
xmlNodeListGetString.  It appears to need "subnode->xmlChildrenNode"
instead of tmp->xmlChildrenNode as its second parameter in order to find
the contained strings.

So, I didn't attach a patch because:

  * I can't claim to be authoritative in my knowledge of the XML
    structures -- this was some late night (or, rather, early morning)
    hacking, and I ran into another obscure problem toward the end in glib
    (which may or not be related -- we're still looking into that).

  * Also, the HTTP response interpretation likely needs some attention
    by those with the "big picture" for Soup.

  * I'm not working from the HEAD branch, mainly because we're using
    the SSL support for our application, and SSL appears to have broken
    severely since 0.7.2.1 (I haven't dipped into that problem yet).
    All of my work last night was against the 0.7.2.1 CVS tag.  However,
    unless I goofed, I didn't see any of these issues addressed in the
    HEAD branch.

My apologies in advance if we're creating problems for the overworked
Soup/Mono team at Ximian -- I recogize that we're likely hitting weak
spots since we're using a SOAP::Lite server instead of the companion
Soup-based SOAP server.  However, at least we can offer some testing &
QA for interoperability!

 -Scott


_______________________________________________
Soup-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/soup-list