From: Adam Dickmeiss Date: Wed, 8 Aug 2012 12:53:22 +0000 (+0200) Subject: Decode SRU 2.0 responses X-Git-Tag: v4.2.36~7 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=2bf750fa7a6e28d9ebb1fabd6325ecf4cfac7e49 Decode SRU 2.0 responses The official namespace for responses, according to http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/cs01/schemas/sruResponse.xsd appears to be http://docs.oasis-open.org/ns/search-ws/sruResponse . nature.com's server, however, usee namespace http://docs.oasis-open.org/ns/search-ws/sru-2-0-response For this reason we are now using a glob-expr to match up the namespace. ZOOM C and yaz-client updated. Perhaps SRU 1.2 uses same namespace, I don't know. I can not find a single real example showing the "real" namespace in the documentation from OASIS. The namespace for requests is different from responses, but this is not added to YAZ yet, when we don't encode them yet. --- diff --git a/client/client.c b/client/client.c index 5af4e26..d8e78b9 100644 --- a/client/client.c +++ b/client/client.c @@ -4458,8 +4458,9 @@ static void http_response(Z_HTTP_Response *hres) { Z_SOAP *soap_package = 0; ODR o = odr_createmem(ODR_DECODE); - Z_SOAP_Handler soap_handlers[3] = { + Z_SOAP_Handler soap_handlers[4] = { {YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec}, + {YAZ_XMLNS_SRU_v2_response, 0, (Z_SOAP_fun) yaz_srw_codec}, {YAZ_XMLNS_UPDATE_v0_9, 0, (Z_SOAP_fun) yaz_ucp_codec}, {0, 0, 0} }; diff --git a/include/yaz/srw.h b/include/yaz/srw.h index cf08af4..8a67ca0 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -335,6 +335,7 @@ void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args); #define YAZ_XMLNS_SRU_v1_1 "http://www.loc.gov/zing/srw/" #define YAZ_XMLNS_DIAG_v1_1 "http://www.loc.gov/zing/srw/diagnostic/" #define YAZ_XMLNS_UPDATE_v0_9 "http://www.loc.gov/zing/srw/update/" +#define YAZ_XMLNS_SRU_v2_response "http://docs.oasis-open.org/ns/search-ws/sru*esponse" YAZ_EXPORT int yaz_srw_check_content_type(Z_HTTP_Response *hres); diff --git a/src/soap.c b/src/soap.c index 5e58a49..0f564b0 100644 --- a/src/soap.c +++ b/src/soap.c @@ -14,6 +14,7 @@ #endif #include +#include #if YAZ_HAVE_XML2 #include @@ -56,7 +57,7 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, /* check for SRU root node match */ for (i = 0; handlers[i].ns; i++) - if (!xmlStrcmp(ptr->ns->href, BAD_CAST handlers[i].ns)) + if (yaz_match_glob(handlers[i].ns, (const char *)ptr->ns->href)) break; if (handlers[i].ns) { @@ -66,7 +67,7 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, p_top_tmp.children = ptr; ret = (*handlers[i].f)(o, &p_top_tmp, &handler_data, handlers[i].client_data, - handlers[i].ns); + (const char *)ptr->ns->href); if (ret || !handler_data) z_soap_error(o, p, "SOAP-ENV:Client", @@ -182,15 +183,19 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, } else { + const char *ns = (const char *) ptr->ns->href; for (i = 0; handlers[i].ns; i++) - if (!xmlStrcmp(ptr->ns->href, BAD_CAST handlers[i].ns)) + { + fprintf(stderr, "checking globns=%s ns=%s\n", + handlers[i].ns, ns); + if (yaz_match_glob(handlers[i].ns, ns)) break; + } if (handlers[i].ns) { void *handler_data = 0; ret = (*handlers[i].f)(o, pptr, &handler_data, - handlers[i].client_data, - handlers[i].ns); + handlers[i].client_data, ns); if (ret || !handler_data) z_soap_error(o, p, "SOAP-ENV:Client", "SOAP Handler returned error", 0); @@ -207,8 +212,7 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, else { ret = z_soap_error(o, p, "SOAP-ENV:Client", - "No handler for NS", - (const char *)ptr->ns->href); + "No handler for NS", ns); } } xmlFreeDoc(doc); diff --git a/src/zoom-sru.c b/src/zoom-sru.c index c38cee6..04aff43 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -425,15 +425,15 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres, { Z_SOAP *soap_package = 0; ODR o = c->odr_in; - Z_SOAP_Handler soap_handlers[2] = { + Z_SOAP_Handler soap_handlers[3] = { {YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec}, + {YAZ_XMLNS_SRU_v2_response, 0, (Z_SOAP_fun) yaz_srw_codec}, {0, 0, 0} }; ret = z_soap_codec(o, &soap_package, &hres->content_buf, &hres->content_len, soap_handlers); - if (!ret && soap_package->which == Z_SOAP_generic && - soap_package->u.generic->no == 0) + if (!ret && soap_package->which == Z_SOAP_generic) { Z_SRW_PDU *sr = (Z_SRW_PDU*) soap_package->u.generic->p;