From 8eb820c6a89f547d079bded098f48e2c9e2fa47c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 1 Feb 2006 15:12:39 +0000 Subject: [PATCH] To stdout output the result as XML. Third attempt to add the XML schema (in new directory). :-) Update tests. --- org.glite.jp.index/Makefile | 6 +-- org.glite.jp.index/examples/jpis-client.c | 57 +++++++++++++++++----- .../interface/JobProvenanceISClient.xsd | 28 +++++++++++ org.glite.jp.index/test/complex_query.in | 4 +- org.glite.jp.index/test/run-test.sh | 4 +- org.glite.jp.index/test/simple_query.in | 5 +- 6 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 org.glite.jp.index/interface/JobProvenanceISClient.xsd diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile index b6ce23d..7fd19bc 100644 --- a/org.glite.jp.index/Makefile +++ b/org.glite.jp.index/Makefile @@ -104,9 +104,9 @@ JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat ${gsoap_bin_prefix}/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $< rm -f JobProvenanceTypes.wsdl -#JobProvenanceISClient.xh: typemap.dat JobProvenanceISClientQuery.xsd JobProvenanceIS.wsdl +#JobProvenanceISClient.xh: typemap.dat JobProvenanceISClient.xsd JobProvenanceIS.wsdl # cp ${stagedir}/interface/JobProvenance{Types.xsd,Types.wsdl,IS.wsdl} . -# ${gsoap_bin_prefix}/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ JobProvenanceIS.wsdl ${top_srcdir}/src/JobProvenanceISClientQuery.xsd +# ${gsoap_bin_prefix}/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ JobProvenanceIS.wsdl ${top_srcdir}/src/JobProvenanceISClient.xsd # rm -f JobProvenance{Types.xsd,Types.wsdl,IS.wsdl} ${is_prefix}ClientLib.c ${is_prefix}Client.c \ @@ -165,7 +165,7 @@ install: ${INSTALL} -m 644 ${top_srcdir}/doc/README ${PREFIX}/share/doc/${package}-${version} ${INSTALL} -m 755 ${test} ${PREFIX}/examples ${INSTALL} -m 644 ${test_files} ${PREFIX}/examples - ${INSTALL} -m 644 ${top_srcdir}/interface/JobProvenanceISClientQuery.xsd ${PREFIX}/interface + ${INSTALL} -m 644 ${top_srcdir}/interface/JobProvenanceISClient.xsd ${PREFIX}/interface clean: diff --git a/org.glite.jp.index/examples/jpis-client.c b/org.glite.jp.index/examples/jpis-client.c index 900727f..a95780b 100644 --- a/org.glite.jp.index/examples/jpis-client.c +++ b/org.glite.jp.index/examples/jpis-client.c @@ -13,10 +13,13 @@ /* 'jpisclient' as future namespace */ #define _jpisclient__QueryJobs _jpelem__QueryJobs +#define _jpisclient__QueryJobsResponse _jpelem__QueryJobsResponse #define soap_default__jpisclient__QueryJobs soap_default__jpelem__QueryJobs #define soap_get__jpisclient__QueryJobs soap_get__jpelem__QueryJobs #define soap_put__jpisclient__QueryJobs soap_put__jpelem__QueryJobs +#define soap_put__jpisclient__QueryJobsResponse soap_put__jpelem__QueryJobsResponse #define soap_serialize__jpisclient__QueryJobs soap_serialize__jpelem__QueryJobs +#define soap_serialize__jpisclient__QueryJobsResponse soap_serialize__jpelem__QueryJobsResponse #define DEFAULT_JPIS "http://localhost:8902" @@ -258,6 +261,22 @@ static int query_example_dump(struct soap *soap, int fd) { /* + * dump the XML query + */ +static int queryresult_dump(struct soap *soap, int fd, struct _jpisclient__QueryJobsResponse *qjr) { + int retval; + + soap->sendfd = fd; + soap_begin_send(soap); + soap_serialize__jpisclient__QueryJobsResponse(soap, qjr); + retval = soap_put__jpisclient__QueryJobsResponse(soap, qjr, "jpisclient:QueryJobsResponse", NULL); + soap_end_send(soap); + + return retval; +} + + +/* * help screen */ static void usage(const char *prog_name) { @@ -325,7 +344,7 @@ static int check_fault(struct soap *soap, int err) { /* * print the data returned from JP IS */ -static void queryJobsResponse_print(FILE *out, const struct _jpelem__QueryJobsResponse *in) { +static void queryresult_print(FILE *out, const struct _jpelem__QueryJobsResponse *in) { struct jptype__attrValue *attr; int i, j; @@ -346,7 +365,7 @@ static void queryJobsResponse_print(FILE *out, const struct _jpelem__QueryJobsR int main(int argc, char * const argv[]) { - struct soap soap; + struct soap soap, soap_comm; struct _jpisclient__QueryJobs qj; char *server, *example_file, *query_file, *test_file; const char *prog_name; @@ -359,12 +378,12 @@ int main(int argc, char * const argv[]) { query_fd = example_fd = test_fd = -1; retval = 1; - /* - * Soap with registered plugin can't be used for reading XML. - * For communications with JP IS glite_gsplugin needs to be registered yet. - */ soap_init(&soap); +#ifdef SOAP_XML_INDENT + soap_omode(&soap, SOAP_XML_INDENT); +#endif + /* * Following code is needed, when we can't combine more XSD/WSDL files * for using both as client. We direct use structures only from @@ -390,15 +409,24 @@ int main(int argc, char * const argv[]) { soap_set_namespaces(&soap, namespaces); } -#ifdef SOAP_XML_INDENT - soap_omode(&soap, SOAP_XML_INDENT); -#endif + /* + * Soap with registered plugin can't be used for reading XML. + * For communications with JP IS glite_gsplugin needs to be registered yet. + */ + soap_init(&soap_comm); + soap_set_namespaces(&soap_comm, jpis_client__namespaces); + soap_register_plugin(&soap_comm, glite_gsplugin); /* program name */ prog_name = strrchr(argv[0], '/'); if (prog_name) prog_name++; else prog_name = argv[0]; + if (argc <= 1) { + usage(prog_name); + goto cleanup; + } + /* handle arguments */ while ((opt = getopt_long(argc, argv, get_opt_string, opts, NULL)) != EOF) switch (opt) { case 'i': @@ -488,16 +516,18 @@ int main(int argc, char * const argv[]) { * structure. Just ugly retype to client here. */ if (query_recv(&soap, query_fd, (struct _jpisclient__QueryJobs *)&in) != 0) { - fprintf(stderr, "test: Error getting query XML\n"); + fprintf(stderr, "query: Error getting query XML\n"); } else { fprintf(stderr, "query: using JPIS %s\n\n", server); query_print(stderr, &in); fprintf(stderr, "\n"); - soap_register_plugin(&soap, glite_gsplugin); - ret = check_fault(&soap, soap_call___jpsrv__QueryJobs(&soap, server, "", &in, &out)); + soap_begin(&soap_comm); + ret = check_fault(&soap_comm, soap_call___jpsrv__QueryJobs(&soap_comm, server, "", &in, &out)); if (ret == 0) { - queryJobsResponse_print(stderr, &out); + queryresult_print(stderr, &out); + queryresult_dump(&soap, STDOUT_FILENO, (struct _jpisclient__QueryJobsResponse *)&out); } else goto cleanup; + soap_end(&soap_comm); } soap_end(&soap); } @@ -506,6 +536,7 @@ int main(int argc, char * const argv[]) { cleanup: soap_done(&soap); + soap_done(&soap_comm); if (example_fd > STDERR_FILENO) close(example_fd); if (query_fd > STDERR_FILENO) close(query_fd); if (test_fd > STDERR_FILENO) close(test_fd); diff --git a/org.glite.jp.index/interface/JobProvenanceISClient.xsd b/org.glite.jp.index/interface/JobProvenanceISClient.xsd new file mode 100644 index 0000000..2cf0755 --- /dev/null +++ b/org.glite.jp.index/interface/JobProvenanceISClient.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.glite.jp.index/test/complex_query.in b/org.glite.jp.index/test/complex_query.in index ecbc3a3..d80b1d5 100644 --- a/org.glite.jp.index/test/complex_query.in +++ b/org.glite.jp.index/test/complex_query.in @@ -1,5 +1,5 @@ - + http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus @@ -32,5 +32,5 @@ http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus http://egee.cesnet.cz/en/Schema/LB/Attributes:user - + diff --git a/org.glite.jp.index/test/run-test.sh b/org.glite.jp.index/test/run-test.sh index 1eb86ca..408a69e 100644 --- a/org.glite.jp.index/test/run-test.sh +++ b/org.glite.jp.index/test/run-test.sh @@ -112,7 +112,7 @@ kill_is() { } run_test_query() { - $GLITE_LOCATION/stage/bin/glite-jpis-client -q $1 \ + $GLITE_LOCATION/stage/examples/glite-jpis-client -q $1 \ -i http://localhost:$GLITE_JPIS_TEST_PORT &>/tmp/result DIFF=`diff --ignore-matching-lines="query: using JPIS" $2 /tmp/result` if [ -z "$DIFF" ] ; then @@ -136,7 +136,7 @@ run_test3() { # run the example numok=`GLITE_JPIS_DB=$GLITE_JPIS_TEST_DB \ GLITE_JPIS_PORT=$GLITE_JPIS_TEST_PORT \ - $GLITE_LOCATION/stage/bin/glite-jpis-test 2>/dev/null| grep "OK" | wc -l` + $GLITE_LOCATION/stage/examples/glite-jpis-test 2>/dev/null| grep "OK" | wc -l` if [ "$numok" -eq "2" ]; then echo OK. fi diff --git a/org.glite.jp.index/test/simple_query.in b/org.glite.jp.index/test/simple_query.in index 00adee1..0b1fe2d 100644 --- a/org.glite.jp.index/test/simple_query.in +++ b/org.glite.jp.index/test/simple_query.in @@ -1,5 +1,5 @@ - + http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus @@ -16,5 +16,4 @@ http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus http://egee.cesnet.cz/en/Schema/LB/Attributes:user - - + -- 1.8.2.3