Happy new year
[yaz-moved-to-github.git] / test / tstsoap2.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2009 Index Data
3  * See the file LICENSE for details.
4  */
5
6 #include <stdlib.h>
7 #include <yaz/test.h>
8 #include <yaz/srw.h>
9 #include <yaz/soap.h>
10
11 #if YAZ_HAVE_XML2
12 #include <libxml/parser.h>
13
14 static void tst_srw(void)
15 {
16     const char *charset = 0;
17     char *content_buf = 0;
18     int content_len;
19     int ret;
20     ODR o = odr_createmem(ODR_ENCODE);
21     Z_SOAP_Handler h[2] = {
22         {"http://www.loc.gov/zing/srw/", 0, (Z_SOAP_fun) yaz_srw_codec},
23         {0, 0, 0}
24     };
25     Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_searchRetrieve_request);
26     Z_SOAP *p = (Z_SOAP *) odr_malloc(o, sizeof(*p));
27
28     YAZ_CHECK(o);
29     YAZ_CHECK(sr);
30     YAZ_CHECK(p);
31 #if 0
32     sr->u.request->query.cql = "jordb" "\xe6" "r"; 
33 #else
34     sr->u.request->query.cql = "jordbaer"; 
35 #endif
36
37     p->which = Z_SOAP_generic;
38     p->u.generic = (Z_SOAP_Generic *) odr_malloc(o, sizeof(*p->u.generic));
39     p->u.generic->no = 0;
40     p->u.generic->ns = 0;
41     p->u.generic->p = sr;
42     p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
43
44     ret = z_soap_codec_enc(o, &p, &content_buf, &content_len, h, charset);
45     odr_destroy(o);
46     YAZ_CHECK(ret == 0);  /* codec failed ? */
47 }
48 #endif
49
50 int main(int argc, char **argv)
51 {
52     YAZ_CHECK_INIT(argc, argv);
53 #if YAZ_HAVE_XML2
54     LIBXML_TEST_VERSION;
55     tst_srw();
56 #endif
57     YAZ_CHECK_TERM;
58 }
59 /*
60  * Local variables:
61  * c-basic-offset: 4
62  * indent-tabs-mode: nil
63  * End:
64  * vim: shiftwidth=4 tabstop=8 expandtab
65  */
66