0
|
1 '''
|
|
2 @author Chaitanya Guttula
|
|
3 @see LICENSE (MIT style license file).
|
|
4 '''
|
|
5
|
|
6 import warnings
|
|
7 with warnings.catch_warnings():
|
|
8 warnings.simplefilter("ignore")
|
|
9 import warnings
|
|
10 import urllib2
|
|
11 import platform
|
|
12 import os,sys
|
|
13 from clientGenerator.creatorEngineComplex import *
|
|
14 from clientGenerator.wsdl2path import *
|
|
15 from clientGenerator.paramConverter import *
|
|
16 from generateClient import *
|
|
17 from generateClient1 import *
|
|
18
|
|
19 '''input : wadl/wsdl/sawadl-url, method name
|
|
20 purpose:
|
|
21 1. Calls methods from generateClient1.py to generate client description for one-time invocation
|
|
22 of the Web service. This client description is added as a xml file under ./clients/
|
|
23 2. Calls methods from generateClient.py to generate client description for invocation of Web service
|
|
24 in a workflow. This client description is added as a xml file under ./workflowclients/
|
|
25 3. Adds the path to the above xml files to Galaxy tool-conf.xml file using call edit_tool_conf.py
|
|
26 '''
|
|
27
|
|
28 servicetype=''
|
|
29
|
|
30 #read the url passed as an argument
|
|
31 url = sys.argv[2]
|
|
32 while(url.find('__tilda__')>-1):
|
|
33 ulist = url.split('__tilda__')
|
|
34 url = '~'.join(ulist)
|
|
35
|
|
36 #split url passed on '.' character
|
|
37 urllist = url.split('/')
|
|
38 wsdlname = urllist[len(urllist)-1].split(".")
|
|
39 if len(wsdlname)==1:
|
|
40 wsdlname =urllist[len(urllist)-1].split('?')
|
|
41
|
|
42 '''#checks the description document (WSDL/WADL) is for SOAP 1.1 or SOAP 2.0 or REST
|
|
43 If the extesnion is wsdl then servicetype is SOAP else If the extension is wadl then servicetype is REST
|
|
44 in other conditions(i.e. the file has no extension)
|
|
45 '''
|
|
46 #u = None
|
|
47 #try:
|
|
48 # u = urllib2.urlopen(url)
|
|
49 #except urllib2.HTTPError, e:
|
|
50 # print e.code
|
|
51 # print e.msg
|
|
52 # print e.headers
|
|
53 # print e.fp.read()
|
|
54 print 'the url is : ',sys.argv[2]
|
|
55 u = urllib2.urlopen(url)
|
|
56 descfile = open('temp','w')
|
|
57 descfile.write(u.read())
|
|
58 descfile.close()
|
|
59 readwsdl = open('temp','r')
|
|
60 tempstring = 'start'
|
|
61
|
|
62 #checks the description document (WSDL/WADL) is for SOAP 1.1 or SOAP 2.0 or REST
|
|
63 while (tempstring != ''):
|
|
64 tempstring = readwsdl.readline()
|
|
65 if tempstring.find('<definitions') != -1 or tempstring.find('<wsdl:definitions') != -1:
|
|
66 print 'WSDL 1.1 or 1.0'
|
|
67 servicetype = 'SOAP'
|
|
68 break
|
|
69 elif tempstring.find('description') != -1:
|
|
70 while tempstring != '':
|
|
71 if tempstring.find('<bindings ') != -1:
|
|
72 bind = tempstring.split('type')
|
|
73 bindLength = len(bind)
|
|
74 bindingtype = bind[bindLength-1]
|
|
75 print bindingtype
|
|
76 break
|
|
77 tempstring = readwsdl.readline()
|
|
78 if bindingtype.find('http://www.w3.org/ns/wsdl/soap') != -1:
|
|
79 servicetype='WSDL2SOAP'
|
|
80 print 'SOAP'
|
|
81 else:
|
|
82 servicetype='WSDL2REST'
|
|
83 break
|
|
84 elif tempstring.find('<application') != -1:
|
|
85 servicetype='REST'
|
|
86 break
|
|
87
|
|
88 readwsdl.close()
|
|
89 operations = sys.argv[3].split(',')
|
|
90
|
|
91 # The webservice is a soap webservice
|
|
92 if servicetype == 'SOAP':
|
|
93
|
|
94 #Create client tool for using web services in workflow
|
|
95 for operation in operations:
|
|
96 if operation != '':
|
|
97 clientGenerator = ClientGenerator(url,operation,sys.argv[4],'SOAP')#webservice,operation,inputl)
|
|
98 if clientGenerator.isToolPresent():
|
|
99 f = open(sys.argv[4],'a')
|
|
100 f.write('The web service workflow tool for service '+url+' and operation '+operation+' was already added to galaxy\n')
|
|
101 else:
|
|
102 clientGenerator.wsdlClient()
|
|
103
|
|
104 #Create cleint tool for invoking web service stand alone
|
|
105 clientGenerator1 = ClientGenerator1(url,operation,sys.argv[4],'SOAP')#webservice,operation,inputl)
|
|
106 if clientGenerator1.isToolPresent():
|
|
107 f = open(sys.argv[4],'a')
|
|
108 f.write('The web service tool for service '+url+' and operation '+operation+' was already added to galaxy\n')
|
|
109 else:
|
|
110 clientGenerator1.wsdlClient()
|
|
111
|
|
112
|
|
113
|
|
114 #Web service is a REST Webservice
|
|
115 elif servicetype == 'REST':
|
|
116
|
|
117 javahome = os.environ.get('JAVA_HOME')
|
|
118 galaxyhome=os.environ.get('GALAXY_HOME')
|
|
119 classpath= galaxyhome + '/tools/WebServiceToolWorkflow_REST_SOAP/ParserForWADL/bin'
|
|
120 jarpath = galaxyhome + '/tools/WebServiceToolWorkflow_REST_SOAP/ParserForWADL/lib/'
|
|
121 machine = platform.machine()
|
|
122
|
|
123 if machine == 'x86_64' :
|
|
124 print 'a'
|
|
125 startJVM("%s/jre/lib/amd64/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
|
|
126 elif machine == 'i686' :
|
|
127 startJVM("%s/jre/lib/i386/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
|
|
128 print 'b'
|
|
129 elif machine == 'sun4u' :
|
|
130 startJVM("%s/jre/lib/sparc/server/libjvm.so" % javahome,"-ea", "-Djava.class.path=%s" % classpath,"-Djava.ext.dirs=%s" % jarpath)
|
|
131 else :
|
|
132 print 'c'
|
|
133 System.exit("Could not identify machine, please specify path to libjvm.so")
|
|
134
|
|
135
|
|
136
|
|
137 for operation in operations:
|
|
138 if(operation != ''):
|
|
139 clientGenerator = ClientGenerator(url,operation,sys.argv[4],'REST')
|
|
140 clientGenerator1 = ClientGenerator1(url,operation,sys.argv[4],'REST')
|
|
141 if clientGenerator.isToolPresent():
|
|
142 f = open(sys.argv[4],'a')
|
|
143 f.write('\nThe web service workflow tool for service '+url+' and operation '+operation+' was already added to galaxy\n')
|
|
144 else:
|
|
145 clientGenerator.wadlClient()
|
|
146 if clientGenerator1.isToolPresent():
|
|
147 f = open(sys.argv[4],'a')
|
|
148 f.write('\nThe web service tool for service '+url+' and operation '+operation+' was already added to galaxy\n')
|
|
149 else:
|
|
150 clientGenerator1.wadlClient()
|
|
151
|
|
152
|
|
153 #shutdownJVM()
|
|
154
|