+int yaz_sru_soap_encode(Z_HTTP_Request *hreq, Z_SRW_PDU *srw_pdu,
+ ODR odr, const char *charset)
+{
+ Z_SOAP_Handler handlers[3] = {
+#if YAZ_HAVE_XML2
+ {YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec},
+ {YAZ_XMLNS_UPDATE_v0_9, 0, (Z_SOAP_fun) yaz_ucp_codec},
+#endif
+ {0, 0, 0}
+ };
+ Z_SOAP *p = (Z_SOAP*) odr_malloc(odr, sizeof(*p));
+
+ z_HTTP_header_add_basic_auth(odr, &hreq->headers,
+ srw_pdu->username, srw_pdu->password);
+ z_HTTP_header_add_content_type(odr,
+ &hreq->headers,
+ "text/xml", charset);
+
+ z_HTTP_header_add(odr, &hreq->headers,
+ "SOAPAction", "\"\"");
+ p->which = Z_SOAP_generic;
+ p->u.generic = (Z_SOAP_Generic *) odr_malloc(odr, sizeof(*p->u.generic));
+ p->u.generic->no = 0;
+ p->u.generic->ns = 0;
+ p->u.generic->p = srw_pdu;
+ p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
+
+#if YAZ_HAVE_XML2
+ if (srw_pdu->which == Z_SRW_update_request ||
+ srw_pdu->which == Z_SRW_update_response)
+ p->u.generic->no = 1; /* second handler */
+#endif
+ return z_soap_codec_enc(odr, &p,
+ &hreq->content_buf,
+ &hreq->content_len, handlers,
+ charset);
+}
+
+Z_SRW_recordVersion *yaz_srw_get_record_versions(ODR odr, int num )
+{
+ Z_SRW_recordVersion *ver
+ = (Z_SRW_recordVersion *) odr_malloc( odr, num * sizeof(*ver) );
+ int i;
+ for ( i=0; i < num; ++i ){
+ ver[i].versionType = 0;
+ ver[i].versionValue = 0;
+ }
+ return ver;
+}
+
+const char *yaz_srw_pack_to_str(int pack)
+{
+ switch(pack)
+ {
+ case Z_SRW_recordPacking_string:
+ return "string";
+ case Z_SRW_recordPacking_XML:
+ return "xml";
+ case Z_SRW_recordPacking_URL:
+ return "url";
+ }
+ return 0;
+}
+
+int yaz_srw_str_to_pack(const char *str)
+{
+ if (!yaz_matchstr(str, "string"))
+ return Z_SRW_recordPacking_string;
+ if (!yaz_matchstr(str, "xml"))
+ return Z_SRW_recordPacking_XML;
+ if (!yaz_matchstr(str, "url"))
+ return Z_SRW_recordPacking_URL;
+ return -1;
+}
+