1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3. SOAP Packages</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="YAZ User's Guide and Reference"><link rel="up" href="soap.html" title="Chapter 8. SOAP and SRU"><link rel="prev" href="soap.http.html" title="2. HTTP"><link rel="next" href="soap.srw.html" title="4. SRU"></head><body><link rel="stylesheet" type="text/css" href="common/style1.css"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3. SOAP Packages</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="soap.http.html">Prev</a> </td><th width="60%" align="center">Chapter 8. SOAP and SRU</th><td width="20%" align="right"> <a accesskey="n" href="soap.srw.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="soap.xml"></a>3. SOAP Packages</h2></div></div></div><p>
2 Every SOAP package in YAZ is represented as follows:
3 </p><pre class="synopsis">
4 #include <yaz/soap.h>
18 #define Z_SOAP_fault 1
19 #define Z_SOAP_generic 2
20 #define Z_SOAP_error 3
25 Z_SOAP_Generic *generic;
26 Z_SOAP_Fault *soap_error;
32 The <code class="literal">fault</code> and <code class="literal">soap_error</code>
33 arms represent both a SOAP fault - struct
34 <code class="literal">Z_SOAP_Fault</code>. Any other generic
35 (valid) package is represented by <code class="literal">Z_SOAP_Generic</code>.
37 The <code class="literal">ns</code> as part of <code class="literal">Z_SOAP</code>
38 is the namespace for SOAP itself and reflects the SOAP
39 version. For version 1.1 it is
40 <code class="literal">http://schemas.xmlsoap.org/soap/envelope/</code>,
42 <code class="literal">http://www.w3.org/2001/06/soap-envelope</code>.
43 </p><pre class="synopsis">
44 int z_soap_codec(ODR o, Z_SOAP **pp,
45 char **content_buf, int *content_len,
46 Z_SOAP_Handler *handlers);
48 The <code class="literal">content_buf</code> and <code class="literal">content_len</code>
49 is XML buffer and length of buffer respectively.
51 The <code class="literal">handlers</code> is a list of SOAP codec
52 handlers - one handler for each service namespace. For SRU SOAP, the
53 namespace would be <code class="literal">http://www.loc.gov/zing/srw/v1.0/</code>.
55 When decoding, the <code class="function">z_soap_codec</code>
56 inspects the XML content
57 and tries to match one of the services namespaces of the
58 supplied handlers. If there is a match a handler function
59 is invoked which decodes that particular SOAP package.
60 If successful, the returned <code class="literal">Z_SOAP</code> package will be
61 of type <code class="literal">Z_SOAP_Generic</code>.
62 Member <code class="literal">no</code> is
63 set the offset of handler that matched; <code class="literal">ns</code>
64 is set to namespace of matching handler; the void pointer
65 <code class="literal">p</code> is set to the C data structure assocatiated
68 When a NULL namespace is met (member <code class="literal">ns</code> bwlow),
69 that specifies end-of-list.
71 Each handler is defined as follows:
72 </p><pre class="synopsis">
79 The <code class="literal">ns</code> is namespace of service associated with
80 handler <code class="literal">f</code>. <code class="literal">client_data</code>
81 is user-defined data which is passed to handler.
83 The prototype for a SOAP service handler is:
84 </p><pre class="synopsis">
85 int handler(ODR o, void * ptr, void **handler_data,
86 void *client_data, const char *ns);
88 The <em class="parameter"><code>o</code></em> specifies the mode (decode/encode)
89 as usual. The second argument, <em class="parameter"><code>ptr</code></em>,
90 is a libxml2 tree node pointer (<code class="literal">xmlNodePtr</code>)
91 and is a pointer to the <code class="literal">Body</code> element
92 of the SOAP package. The <em class="parameter"><code>handler_data</code></em>
93 is an opaque pointer to a C definitions associated with the
94 SOAP service. <em class="parameter"><code>client_data</code></em> is the pointer
95 which was set as part of the <code class="literal">Z_SOAP_handler</code>.
96 Finally, <em class="parameter"><code>ns</code></em> the service namespace.
97 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="soap.http.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="soap.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="soap.srw.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. HTTP </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4. SRU</td></tr></table></div></body></html>