1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
10 Z_SOAP_Handler h[2] = {
11 {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
15 int main(int argc, char **argv)
18 char *content_buf = buf;
22 Z_SOAP *soap_package = 0;
26 if (argc == 2 && !strcmp(argv[1], "debug"))
28 no = fread(buf, 1, sizeof(buf), stdin);
29 if (no < 1 || no == sizeof(buf))
31 fprintf(stderr, "Bad file or too big\n");
34 decode = odr_createmem(ODR_DECODE);
35 encode = odr_createmem(ODR_ENCODE);
37 ret = z_soap_codec(decode, &soap_package,
38 &content_buf, &content_len, h);
41 fprintf(stderr, "Decoding seriously failed\n");
46 fprintf(stderr, "got NS = %s\n", soap_package->ns);
47 if (soap_package->which == Z_SOAP_generic &&
48 soap_package->u.generic->no == 0)
50 Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p;
51 if (sr->which == Z_SRW_searchRetrieve_request)
53 Z_SRW_searchRetrieveRequest *req = sr->u.request;
54 switch(req->query_type)
56 case Z_SRW_query_type_cql:
57 fprintf(stderr, "CQL: %s\n", req->query.cql);
59 case Z_SRW_query_type_xcql:
60 fprintf(stderr, "XCQL\n");
62 case Z_SRW_query_type_pqf:
63 fprintf(stderr, "PQF: %s\n", req->query.pqf);
67 else if (sr->which == Z_SRW_searchRetrieve_response)
69 Z_SRW_searchRetrieveResponse *res = sr->u.response;
70 if (res->records && res->num_records)
73 for (i = 0; i<res->num_records; i++)
75 fprintf (stderr, "%d\n", i);
76 if (res->records[i].recordData_buf)
77 fwrite(res->records[i].recordData_buf, 1,
78 res->records[i].recordData_len, stderr);
85 ret = z_soap_codec(encode, &soap_package,
86 &content_buf, &content_len, h);
87 if (content_buf && content_len)
88 fwrite (content_buf, content_len, 1, stdout);
91 fprintf(stderr, "No output!\n");
99 int main(int argc, char **argv)
101 fprintf(stderr, "SOAP disabled\n");
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab