added lb4agu examples
authorJan Pospíšil <honik@ntc.zcu.cz>
Sun, 6 Dec 2009 19:39:40 +0000 (19:39 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Sun, 6 Dec 2009 19:39:40 +0000 (19:39 +0000)
org.glite.lb.ws-test/Makefile
org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.c [new file with mode: 0644]
org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.pl [new file with mode: 0755]

index 7b2b5a7..81759cb 100644 (file)
@@ -18,7 +18,7 @@ voms_prefix=/opt/voms
 
 version=${module.version}
 
-CEXAMPLES:=ws_getversion ws_jobstat ws_joblog
+CEXAMPLES:=ws_getversion ws_jobstat ws_joblog ws_lb4agu_GetActivityStatus
 #TODO ws_query_ex 
 
 default all: ${CEXAMPLES}
diff --git a/org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.c b/org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.c
new file mode 100644 (file)
index 0000000..2af5f2f
--- /dev/null
@@ -0,0 +1,104 @@
+#include <getopt.h>
+#include <stdsoap2.h>
+
+#include "soap_version.h"
+#include "glite/security/glite_gsplugin.h"
+#include "glite/security/glite_gscompat.h"
+
+#include "bk_ws_H.h"
+
+#include "LoggingAndBookkeeping.nsmap"
+
+static struct option opts[] = {
+       {"help",        0,      NULL,   'h'},
+       {"server",      1,      NULL,   'm'},
+       {"jobid",       1,      NULL,   'j'}
+};
+
+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-j, --jobid     ID of requested job.\n"
+               , me);
+}
+
+int main(int argc,char** argv)
+{
+       glite_gsplugin_Context                          gsplugin_ctx;
+       struct soap                                     *mydlo = soap_new();
+       struct _lb4ague__GetActivityStatusRequest       *in;    
+       struct _lb4ague__GetActivityStatusResponse      *out;
+       int                                             opt, err;
+       char                                            *server = "http://localhost:9003/",
+                                                       *jobid = NULL,
+                                                       *name = NULL;
+
+
+       name = strrchr(argv[0],'/');
+       if (name) name++; else name = argv[0];
+
+       while ((opt = getopt_long(argc, argv, "hm:j:", opts, NULL)) != EOF) switch (opt)
+       {
+       case 'h': usage(name); return 0;
+       case 'm': server = optarg; break;
+       case 'j': jobid = optarg; break;
+       case '?': usage(name); return 1;
+       }
+
+       if ( !jobid )
+       {
+               printf("jobid should be given\n");
+               usage(name);
+               return 1;
+       }
+               
+       soap_set_namespaces(mydlo, namespaces);
+       glite_gsplugin_init_context(&gsplugin_ctx);
+
+       if ( soap_register_plugin_arg(mydlo, glite_gsplugin, (void *)gsplugin_ctx) )
+       {
+               soap_print_fault(mydlo, stderr);
+               return 1;
+       }
+
+
+       in = soap_malloc(mydlo, sizeof(*in));
+       out = soap_malloc(mydlo, sizeof(*out));
+       in->id[0] = soap_strdup(mydlo, jobid);
+
+       switch (err = soap_call___lb4agu__GetActivityStatus(mydlo, server, "",in,out)) {
+       case SOAP_OK:
+               {
+               struct soap     *outsoap = soap_new();;
+
+               outsoap->sendfd = 1;
+               soap_serialize_PointerTo_lb4ague__GetActivityStatusResponse(outsoap,&out);
+               soap_begin_send(outsoap);
+               soap_put_PointerTo_lb4ague__GetActivityStatusResponse(outsoap,&out,"status","http://glite.org/wsdl/services/lb4agu:GetActivityStatusResponse");
+               soap_end_send(outsoap);
+               }
+               break;
+       case SOAP_FAULT: 
+       case SOAP_SVR_FAULT:
+               {
+               char    *et;
+               int err;
+
+               err = glite_lb_FaultToErr(mydlo,&et);
+               fprintf(stderr,"%s: %s (%s)\n",argv[0],strerror(err),et);
+               exit(1);
+               }
+       default:
+               fprintf(stderr,"err = %d\n",err);
+               soap_print_fault(mydlo,stderr);
+    }
+
+    soap_end(mydlo);
+    soap_done(mydlo);
+    free(mydlo);
+    glite_gsplugin_free_context(gsplugin_ctx);
+
+    return 0;
+}
diff --git a/org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.pl b/org.glite.lb.ws-test/examples/ws_lb4agu_GetActivityStatus.pl
new file mode 100755 (executable)
index 0000000..e3cdd36
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+# version known to support enough from document/literal to work
+use SOAP::Lite 0.69;
+
+use Data::Dumper;
+
+$ENV{HTTPS_CA_DIR}='/etc/grid-security/certificates';
+$ENV{HTTPS_VERSION}='3';
+
+$ENV{HTTPS_CA_FILE}= $ENV{HTTPS_CERT_FILE} = $ENV{HTTPS_KEY_FILE} =
+       $ENV{X509_USER_PROXY} ? $ENV{X509_USER_PROXY} : "/tmp/x509up_u$<";
+
+die "usage: $0 jobid\n" unless $#ARGV == 0;
+
+$job = shift;
+
+$job =~ ?https://([^:]*):([0-9]*)/(.*)?;
+$port = $2 + 3;
+$srv = "https://$1:$port/lb";
+
+
+$c = SOAP::Lite
+       -> uri('http://glite.org/wsdl/services/lb')
+       -> proxy($srv) ;
+
+
+# TODO: replace with $srv/lb/?wsdl once it works
+service $c 'LB.wsdl';
+
+$c->serializer->register_ns('http://glite.org/wsdl/services/lb4agu','lb4agu');
+# ns $c 'http://glite.org/wsdl/elements/lb';
+
+$req = SOAP::Data->value(
+               SOAP::Data->name(id => $job),
+       );
+
+on_fault $c sub { print Dumper($_[1]->fault); $fault = 1; };
+
+$resp = $c -> JobStatus($req);
+
+print Dumper($resp->result),"\n";
+