source: TI03-DataExtractor/branches/old_stuff/dx-webservice/dxSoapClient.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/dx-webservice/dxSoapClient.py@793
Revision 793, 2.6 KB checked in by astephen, 13 years ago (diff)

Put all the old code in the old_stuff branch.

Line 
1#!/usr/bin/env python
2"""
3dxSoapClient.py
4===============
5
6A simple web service client calling the ControlExtract class.
7
8"""
9
10import sys
11sys.path.append('/usr/local/src/soap/SOAPpy-0.11.6/build/lib')
12
13def runClient1():
14   from SOAPpy import SOAPProxy
15   print "Connecting to the server..."
16   server = SOAPProxy("http://localhost:8443/") # port must be same as server
17   print "Get some feedback from the dx"
18   print "Return value:",server.callControlExtractClass()
19   
20def makeDateParts(start,end, varnum="1"):
21   nd={start:"start", end:"end"}
22   for lim in ("start", "end"):
23       b=__builtins__
24       c=0
25       for i in ("year", "month", "day", "hour", "min", "sec"):
26           if i=="year":
27               e=c+4
28           else:
29               e=c+2
30           setattr(b, "%s_%s_%s" % (lim, i, varnum), nd[lim][c:c+e])
31           c=c+e
32   return 
33   
34def optionSummariser(dxSoapObject):
35    opts=dxSoapObject._asdict().options
36    print "\n"+"*"*40
37    print "Data Extractor options available for '%s' are:\n" % opts["category"]
38    for opt in opts["choices"]:
39        print opt
40       
41def requestSummariser(dxSoapObject):
42    req=dxSoapObject.request._asdict()
43    print "\n"+"*"*40
44    print "Summary of current request follows:\n"
45    for key in req.keys():
46        print "%s%s" % (key, req[key])   
47       
48def runClient2():
49    from SOAPpy import SOAPProxy,Config
50    Config.debug=0
51    print "Connecting to the server..."
52    server = SOAPProxy("http://localhost:8443/") # port must be same as server
53    print "Get some feedback from the dx"
54    rt1=server.callControlExtractClass() 
55    sessionID=rt1.request["req_id"]
56    print rt1.request
57    rt2=server.callControlExtractClass(dataset_group_1="Test Data Group 1",
58                   req_id=sessionID)
59    requestSummariser(rt2)
60
61
62    rt3=server.callControlExtractClass(dataset_1="Test Dataset 1",
63                   req_id=sessionID)
64    requestSummariser(rt3)
65
66    rt4=server.callControlExtractClass(variable_1="My test variable [pqn]", 
67                  req_id=sessionID)
68    requestSummariser(rt4)
69
70    rt5=server.callControlExtractClass(req_id=sessionID, northernExtent="90", westernExtent="30",
71       easternExtent="90", southernExtent="0", vertical_domain_1="Single level",
72       start_year_1="1999", start_month_1="01", start_day_1="00", start_hour_1="01",
73       start_min_1="00", start_sec_1="00", end_year_1="1999", end_month_1="01", 
74       end_day_1="01", end_hour_1="00", end_min_1="00", end_sec_1="01", 
75       output_type="NetCDF", target_page="ResultsPage", time_interval_value_1="6",
76       time_interval_units_1="hours") 
77    requestSummariser(rt5)
78 
79if __name__=="__main__":
80    runClient2()
Note: See TracBrowser for help on using the repository browser.