To stdout output the result as XML.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 1 Feb 2006 15:12:39 +0000 (15:12 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 1 Feb 2006 15:12:39 +0000 (15:12 +0000)
Third attempt to add the XML schema (in new directory). :-)
Update tests.

org.glite.jp.index/Makefile
org.glite.jp.index/examples/jpis-client.c
org.glite.jp.index/interface/JobProvenanceISClient.xsd [new file with mode: 0644]
org.glite.jp.index/test/complex_query.in
org.glite.jp.index/test/run-test.sh
org.glite.jp.index/test/simple_query.in

index b6ce23d..7fd19bc 100644 (file)
@@ -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:
 
index 900727f..a95780b 100644 (file)
 
 /* '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 (file)
index 0000000..2cf0755
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            xmlns:jpt="http://glite.org/wsdl/types/jp"
+            targetNamespace="http://glite.org/xsd/types/jpisclient"
+elementFormDefault="unqualified" attributeFormDefault="unqualified">
+
+<xsd:import namespace="http://glite.org/wsdl/types/jp" 
+            schemaLocation="JobProvenanceTypes.xsd"/>
+
+<xsd:element name="QueryJobs">
+  <xsd:complexType mixed="true">
+    <xsd:sequence>
+      <xsd:element name="conditions" type="jpt:indexQuery" minOccurs="1" maxOccurs="unbounded"/>
+      <xsd:element name="attributes" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
+    </xsd:sequence>
+  </xsd:complexType>
+</xsd:element>
+
+<xsd:element name="QueryJobsResponse">
+  <xsd:complexType>
+    <xsd:sequence>
+      <xsd:element name="jobs" type="jpt:jobRecord" minOccurs="1" maxOccurs="unbounded"/>
+    </xsd:sequence>
+  </xsd:complexType>
+</xsd:element>
+
+</xsd:schema>
index ecbc3a3..d80b1d5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<queryJobs xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jptype="http://glite.org/wsdl/types/jp" xmlns:jpsrv="http://glite.org/wsdl/services/jp" xmlns:jpelem="http://glite.org/wsdl/elements/jp" xsi:type="indexQuery">
+<jpisclient:QueryJobs xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jptype="http://glite.org/wsdl/types/jp" xmlns:jpsrv="http://glite.org/wsdl/services/jp" xmlns:jpelem="http://glite.org/wsdl/elements/jp" xmlns:jpisclient="http://glite.org/xsd/types/jpisclient">
 
        <conditions>
                <attr>http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus</attr>
@@ -32,5 +32,5 @@
        <attributes>http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus</attributes>
        <attributes>http://egee.cesnet.cz/en/Schema/LB/Attributes:user</attributes>
 
-</queryJobs>
+</jpisclient:QueryJobs>
 
index 1eb86ca..408a69e 100644 (file)
@@ -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
index 00adee1..0b1fe2d 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<queryJobs xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jptype="http://glite.org/wsdl/types/jp" xmlns:jpsrv="http://glite.org/wsdl/services/jp" xmlns:jpelem="http://glite.org/wsdl/elements/jp" xsi:type="indexQuery">
+<jpisclient:QueryJobs xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jptype="http://glite.org/wsdl/types/jp" xmlns:jpsrv="http://glite.org/wsdl/services/jp" xmlns:jpelem="http://glite.org/wsdl/elements/jp" xmlns:jpisclient="http://glite.org/xsd/types/jpisclient">
 
        <conditions>
                <attr>http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus</attr>
@@ -16,5 +16,4 @@
        <attributes>http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus</attributes>
        <attributes>http://egee.cesnet.cz/en/Schema/LB/Attributes:user</attributes>
 
-</queryJobs>
-
+</jpisclient:QueryJobs>