GetInterfaceVersion implementation (SB #37335).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 2 Feb 2011 15:13:05 +0000 (15:13 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 2 Feb 2011 15:13:05 +0000 (15:13 +0000)
org.glite.lb.server/src/ws_query.c
org.glite.lb.ws-interface/Makefile
org.glite.lb.ws-interface/src/LB.xml
org.glite.lb.ws-test/examples/ws_getversion.c

index 1c8d73e..78e0f90 100644 (file)
@@ -21,6 +21,7 @@ limitations under the License.
 #include "glite/lb/context-int.h"
 #include "glite/lb/xml_parse.h"
 #include "glite/lb/xml_conversions.h"
+#include "glite/lb/ws_interface_version.h"
 
 #include "glite/lbu/log.h"
 
@@ -65,6 +66,20 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__GetVersion(
 }
 
 
+SOAP_FMAC5 int SOAP_FMAC6 __lb__GetInterfaceVersion(
+       struct soap* soap,
+       struct _lbe__GetInterfaceVersion *in,
+       struct _lbe__GetInterfaceVersionResponse *out)
+{
+       glite_common_log(LOG_CATEGORY_LB_SERVER_REQUEST, LOG_PRIORITY_DEBUG, 
+               "[%d] WS call %s", getpid(), __FUNCTION__);
+
+       out->version = soap_strdup(soap, GLITE_LB_WS_INTERFACE_VERSION);
+
+       return out->version ? SOAP_OK : SOAP_FAULT;
+}
+
+
 SOAP_FMAC5 int SOAP_FMAC6 __lb__JobStatus(
        struct soap     *soap,
        struct _lbe__JobStatus *in,
index 03da05d..e5d2992 100644 (file)
@@ -27,7 +27,7 @@ STAGETO=interface
 
 WSDL=LB.wsdl LBTypes.wsdl
 
-all compile: ${WSDL} ${doc} glue2-copy.xsd
+all compile: ${WSDL} ${doc} glue2-copy.xsd ws_interface_version.h
 
 check: 
        @echo No unit test required for interface-only module.
@@ -49,6 +49,7 @@ install:
        install -m 644 ${WSDL} ${PREFIX}/${STAGETO}
        install -m 644 glue2-copy.xsd ${PREFIX}/${STAGETO}/glue2.xsd
        install -m 644 ${top_srcdir}/src/lb4agu.wsdl ${PREFIX}/${STAGETO}
+       install -m 644 ws_interface_version.h ${PREFIX}/include/${globalprefix}/${lbprefix}
 
 # JP has its own version anyway
 #      if [ x${DOSTAGE} = xyes ]; then \
@@ -78,3 +79,5 @@ LB.html: doc.xml LBTypes.xml LB.xml puke-ug.xsl
        ${XSLTPROC} --stringparam  chapter.autolabel 0 ${docbookxls} doc-html.xml >$@
        -${TIDY} -asxhtml -m $@
 
+ws_interface_version.h: ${top_srcdir}/project/version.properties
+       echo "#define GLITE_LB_WS_INTERFACE_VERSION \"${version}\"" >$@
index 780c687..6cc55da 100644 (file)
                        <output name="version" type="xsd:string">Returned version.</output>
                        <fault name="genericFault" type="genericFault"> Any error. </fault>
                </op>
+               <op name="GetInterfaceVersion">
+                       Return version of the service interface.
+                       <input name="dummy" type="xsd:string" optional="yes">Dummy parameter (workaround for gSoap).</input>
+                       <output name="version" type="xsd:string">Returned version.</output>
+                       <fault name="genericFault" type="genericFault"> Any error. </fault>
+               </op>
                <op name="JobStatus">
                        Query state of a single job.
                        <input name="jobid" type="xsd:string"> Id of the queried job. </input>
index 4049344..6634b20 100644 (file)
@@ -33,6 +33,7 @@ limitations under the License.
 static struct option opts[] = {
        {"help",        0,      NULL,   'h'},
        {"server",      1,      NULL,   'm'},
+       {"interface",   0,      NULL,   'i'},
 };
 
 static void usage(char *me)
@@ -40,6 +41,7 @@ static void usage(char *me)
        fprintf(stderr,"usage: %s [option]\n"
                "\t-h, --help      Shows this screen.\n"
                "\t-m, --server    BK server address:port.\n"
+               "\t-i, --interface Get web-service interface version (server version is returned by default).\n"
                , me);
 }
 
@@ -47,20 +49,20 @@ int main(int argc,char** argv)
 {
        glite_gsplugin_Context          gsplugin_ctx;
        struct soap                     soap;
-       struct _lbe__GetVersion         in;
-       struct _lbe__GetVersionResponse out;
        int                             opt, err;
        char                            *server = "http://localhost:9003/",
                                        *name = NULL;
-
+       int                             iface = 0;
+       char                            *version = NULL;
 
        name = strrchr(argv[0],'/');
        if (name) name++; else name = argv[0];
 
-       while ((opt = getopt_long(argc, argv, "hm:", opts, NULL)) != EOF) switch (opt)
+       while ((opt = getopt_long(argc, argv, "hm:i", opts, NULL)) != EOF) switch (opt)
        {
        case 'h': usage(name); return 0;
        case 'm': server = optarg; break;
+       case 'i': iface = 1; break;
        case '?': usage(name); return 1;
        }
 
@@ -75,11 +77,27 @@ int main(int argc,char** argv)
                return 1;
        }
 
-    memset(&in, 0, sizeof(in));
-    memset(&out, 0, sizeof(out));
-    switch (err = soap_call___lb__GetVersion(&soap, server, "", &in, &out))
+       if (iface) {
+               struct _lbe__GetInterfaceVersion                in;
+               struct _lbe__GetInterfaceVersionResponse        out;
+
+               memset(&in, 0, sizeof(in));
+               memset(&out, 0, sizeof(out));
+               err = soap_call___lb__GetInterfaceVersion(&soap, server, "", &in, &out);
+               if (err == SOAP_OK) version = out.version;
+       } else {
+               struct _lbe__GetVersion         in;
+               struct _lbe__GetVersionResponse out;
+
+               memset(&in, 0, sizeof(in));
+               memset(&out, 0, sizeof(out));
+               err = soap_call___lb__GetVersion(&soap, server, "", &in, &out);
+               if (err == SOAP_OK) version = out.version;
+       }
+
+    switch (err)
        {
-       case SOAP_OK: printf("Server version: %s\n", out.version); break;
+       case SOAP_OK: printf("%s version: %s\n", iface ? "Interface" : "Server", version); break;
        case SOAP_FAULT: 
        case SOAP_SVR_FAULT:
                {