2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: srwtst.c,v 1.3 2005-01-17 13:09:43 adam Exp $
12 Z_SOAP_Handler h[2] = {
13 {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
17 int main(int argc, char **argv)
20 char *content_buf = buf;
24 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 = 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)
80 fwrite(res->records[i].recordData_buf, 1,
81 res->records[i].recordData_len, stderr);
88 ret = z_soap_codec(encode, &soap_package,
89 &content_buf, &content_len, h);
90 if (content_buf && content_len)
91 fwrite (content_buf, content_len, 1, stdout);
94 fprintf(stderr, "No output!\n");
103 int main(int argc, char **argv)
105 fprintf(stderr, "SOAP disabled\n");