1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 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;
25 Z_SOAP *soap_package = 0;
29 if (argc == 2 && !strcmp(argv[1], "debug"))
31 no = fread(buf, 1, sizeof(buf), stdin);
32 if (no < 1 || no == sizeof(buf))
34 fprintf(stderr, "Bad file or too big\n");
37 decode = odr_createmem(ODR_DECODE);
38 encode = odr_createmem(ODR_ENCODE);
40 ret = z_soap_codec(decode, &soap_package,
41 &content_buf, &content_len, h);
44 fprintf(stderr, "Decoding seriously failed\n");
49 fprintf(stderr, "got NS = %s\n", soap_package->ns);
50 if (soap_package->which == Z_SOAP_generic &&
51 soap_package->u.generic->no == 0)
53 Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p;
54 if (sr->which == Z_SRW_searchRetrieve_request)
56 Z_SRW_searchRetrieveRequest *req = sr->u.request;
57 switch(req->query_type)
59 case Z_SRW_query_type_cql:
60 fprintf(stderr, "CQL: %s\n", req->query.cql);
62 case Z_SRW_query_type_xcql:
63 fprintf(stderr, "XCQL\n");
65 case Z_SRW_query_type_pqf:
66 fprintf(stderr, "PQF: %s\n", req->query.pqf);
70 else if (sr->which == Z_SRW_searchRetrieve_response)
72 Z_SRW_searchRetrieveResponse *res = sr->u.response;
73 if (res->records && res->num_records)
76 for (i = 0; i<res->num_records; i++)
78 fprintf (stderr, "%d\n", i);
79 if (res->records[i].recordData_buf)
81 fprintf(stderr, "%.*s",
82 res->records[i].recordData_len,
83 res->records[i].recordData_buf);
91 ret = z_soap_codec(encode, &soap_package,
92 &content_buf, &content_len, h);
93 if (content_buf && content_len)
95 printf("%.*s", content_len, content_buf);
99 fprintf(stderr, "No output!\n");
107 int main(int argc, char **argv)
109 fprintf(stderr, "SOAP disabled\n");
116 * c-file-style: "Stroustrup"
117 * indent-tabs-mode: nil
119 * vim: shiftwidth=4 tabstop=8 expandtab