1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2012 Index Data
3 * See the file LICENSE for details.
13 Z_SOAP_Handler h[2] = {
14 {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
18 int main(int argc, char **argv)
21 char *content_buf = buf;
24 Z_SOAP *soap_package = 0;
28 if (argc == 2 && !strcmp(argv[1], "debug"))
30 no = fread(buf, 1, sizeof(buf), stdin);
31 if (no < 1 || no == sizeof(buf))
33 fprintf(stderr, "Bad file or too big\n");
36 decode = odr_createmem(ODR_DECODE);
37 encode = odr_createmem(ODR_ENCODE);
39 z_soap_codec(decode, &soap_package,
40 &content_buf, &content_len, h);
43 fprintf(stderr, "Decoding seriously failed\n");
48 fprintf(stderr, "got NS = %s\n", soap_package->ns);
49 if (soap_package->which == Z_SOAP_generic &&
50 soap_package->u.generic->no == 0)
52 Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p;
53 if (sr->which == Z_SRW_searchRetrieve_request)
55 Z_SRW_searchRetrieveRequest *req = sr->u.request;
56 switch(req->query_type)
58 case Z_SRW_query_type_cql:
59 fprintf(stderr, "CQL: %s\n", req->query.cql);
61 case Z_SRW_query_type_xcql:
62 fprintf(stderr, "XCQL\n");
64 case Z_SRW_query_type_pqf:
65 fprintf(stderr, "PQF: %s\n", req->query.pqf);
69 else if (sr->which == Z_SRW_searchRetrieve_response)
71 Z_SRW_searchRetrieveResponse *res = sr->u.response;
72 if (res->records && res->num_records)
75 for (i = 0; i<res->num_records; i++)
77 fprintf (stderr, "%d\n", i);
78 if (res->records[i].recordData_buf)
80 fprintf(stderr, "%.*s",
81 res->records[i].recordData_len,
82 res->records[i].recordData_buf);
90 z_soap_codec(encode, &soap_package, &content_buf, &content_len, h);
91 if (content_buf && content_len)
93 printf("%.*s", content_len, content_buf);
97 fprintf(stderr, "No output!\n");
105 int main(int argc, char **argv)
107 fprintf(stderr, "SOAP disabled\n");
114 * c-file-style: "Stroustrup"
115 * indent-tabs-mode: nil
117 * vim: shiftwidth=4 tabstop=8 expandtab