From: Adam Dickmeiss Date: Fri, 20 Dec 2013 10:09:18 +0000 (+0100) Subject: For SOAP decoding, allow handler[i].ns to hold element X-Git-Tag: v5.0.9~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=fb14e7c421cd6539e67cebf31cb8a7787161937c;p=yaz-moved-to-github.git For SOAP decoding, allow handler[i].ns to hold element It's assumed to be a namespace if it has a colon in it, and an element otherwise. Part of YAZ-716 . --- diff --git a/src/soap.c b/src/soap.c index 94b6726..786b896 100644 --- a/src/soap.c +++ b/src/soap.c @@ -48,17 +48,27 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, "Bad XML Document", 0); ptr = xmlDocGetRootElement(doc); - if (!ptr || !ptr->ns) + if (!ptr || ptr->type != XML_ELEMENT_NODE || !ptr->ns) { xmlFreeDoc(doc); return z_soap_error(o, p, "SOAP-ENV:Client", "No Envelope element", 0); } /* check for SRU root node match */ - for (i = 0; handlers[i].ns; i++) - if (yaz_match_glob(handlers[i].ns, (const char *)ptr->ns->href)) - break; + { + const char *hns = handlers[i].ns; + if (strchr(hns, ':')) + { + if (yaz_match_glob(hns, (const char *) ptr->ns->href)) + break; + } + else + { + if (yaz_match_glob(hns, (const char *) ptr->name)) + break; + } + } if (handlers[i].ns) { void *handler_data = 0; @@ -85,9 +95,7 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, return ret; } /* OK: assume SOAP */ - - if (!ptr || ptr->type != XML_ELEMENT_NODE || - xmlStrcmp(ptr->name, BAD_CAST "Envelope") || !ptr->ns) + if (xmlStrcmp(ptr->name, BAD_CAST "Envelope")) { xmlFreeDoc(doc); return z_soap_error(o, p, "SOAP-ENV:Client", @@ -186,7 +194,8 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, const char *ns = (const char *) ptr->ns->href; for (i = 0; handlers[i].ns; i++) { - if (yaz_match_glob(handlers[i].ns, ns)) + if (strchr(handlers[i].ns, ':') && + yaz_match_glob(handlers[i].ns, ns)) break; } if (handlers[i].ns)