* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: soap.c,v 1.6 2003-03-11 11:09:17 adam Exp $
+ * $Id: soap.c,v 1.9 2003-04-23 20:36:05 adam Exp $
*/
#include <yaz/soap.h>
return -1;
}
-int z_soap_codec(ODR o, Z_SOAP **pp,
- char **content_buf, int *content_len,
- Z_SOAP_Handler *handlers)
-{
- return z_soap_codec_enc(o, pp, content_buf, content_len, handlers, 0);
-}
-
int z_soap_codec_enc(ODR o, Z_SOAP **pp,
char **content_buf, int *content_len,
Z_SOAP_Handler *handlers,
Z_SOAP *p = *pp;
xmlNsPtr ns_env;
xmlNodePtr envelope_ptr, body_ptr;
- xmlChar *buf_out;
- int len_out;
xmlDocPtr doc = xmlNewDoc("1.0");
if (ret)
return ret;
}
- if (encoding)
- xmlDocDumpMemoryEnc(doc, &buf_out, &len_out, encoding);
- else
- xmlDocDumpMemory(doc, &buf_out, &len_out);
- *content_buf = (char *) odr_malloc(o, len_out);
- *content_len = len_out;
- memcpy(*content_buf, buf_out, len_out);
- xmlFree(buf_out);
+ if (p->which == Z_SOAP_generic && !strcmp(p->ns, "SRU"))
+ {
+ xmlDocSetRootElement(doc, body_ptr->children);
+ }
+ if (1)
+ {
+ xmlChar *buf_out;
+ int len_out;
+ if (encoding)
+ xmlDocDumpMemoryEnc(doc, &buf_out, &len_out, encoding);
+ else
+ xmlDocDumpMemory(doc, &buf_out, &len_out);
+ *content_buf = (char *) odr_malloc(o, len_out);
+ *content_len = len_out;
+ memcpy(*content_buf, buf_out, len_out);
+ xmlFree(buf_out);
+ }
xmlFreeDoc(doc);
return 0;
}
return 0;
}
#else
-int z_soap_codec(ODR o, Z_SOAP **pp,
- char **content_buf, int *content_len,
- Z_SOAP_Handler *handlers)
+int z_soap_codec_enc(ODR o, Z_SOAP **pp,
+ char **content_buf, int *content_len,
+ Z_SOAP_Handler *handlers, const char *encoding)
{
- const char *err_xml =
+ static char *err_xml =
"<?xml version=\"1.0\"?>\n"
"<SOAP-ENV:Envelope"
" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
return -1;
}
#endif
+int z_soap_codec(ODR o, Z_SOAP **pp,
+ char **content_buf, int *content_len,
+ Z_SOAP_Handler *handlers)
+{
+ return z_soap_codec_enc(o, pp, content_buf, content_len, handlers, 0);
+}
+