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 platform
|
|
10 import os
|
|
11 import sys
|
|
12 import ZSI
|
|
13 import commands
|
|
14 from clientGenerator.creatorEngineComplex import *
|
|
15 from clientGenerator.wsdl2path import *
|
|
16 import urllib2
|
|
17 from getMethods_m import *
|
|
18
|
|
19 '''
|
|
20 Takes the description document as input and parses the document and
|
|
21 gets all the operations available in the web service and provides it
|
|
22 Galaxy
|
|
23
|
|
24 '''
|
|
25
|
|
26 url = sys.argv[1]
|
|
27 while(url.find('__tilda__')>-1):
|
|
28 ulist = url.split('__tilda__')
|
|
29 url = '~'.join(ulist)
|
|
30 urllist = url.split('/')
|
|
31 wsdlname = urllist[len(urllist)-1].split(".")
|
|
32 if len(wsdlname)==1:
|
|
33 wsdlname =urllist[len(urllist)-1].split('?')
|
|
34
|
|
35 servicetype = ''
|
|
36
|
|
37 #instantiate a Document
|
|
38 descriptionDocument = Document()
|
|
39
|
|
40 #if wsdlname[-1] == 'wsdl' or wsdlname[-1] == 'WSDL':
|
|
41 # servicetype='SOAP'
|
|
42 #elif wsdlname[-1] == 'wadl' or wsdlname[-1] == 'WADL':
|
|
43 # servicetype='REST'
|
|
44 #else:
|
|
45
|
|
46 try:
|
|
47 u = urllib2.urlopen(url)
|
|
48 except urllib2.HTTPError, e:
|
|
49 print e.code
|
|
50 print e.msg
|
|
51 print e.headers
|
|
52 print e.fp.read()
|
|
53
|
|
54 descfile = open('temp','w')
|
|
55 descfile.write(u.read())
|
|
56 descfile.close()
|
|
57 readwsdl = open('temp','r')
|
|
58 tempstring = 'start'
|
|
59
|
|
60 #checks the description document (WSDL/WADL) is for SOAP 1.1 or SOAP 2.0 or REST and gets the operations in the web service accordingly
|
|
61 while (tempstring != ''):
|
|
62 tempstring = readwsdl.readline()
|
|
63 #If its WSDL 1.0/1.1
|
|
64 if tempstring.find('<definitions') != -1 or tempstring.find('<wsdl:definitions') != -1:
|
|
65 servicetype = 'SOAP'
|
|
66 descriptionDocument.getWSDLMethods(url,sys.argv[2])
|
|
67 break
|
|
68 #if it is WSDL 2.0
|
|
69 elif tempstring.find('<description') != -1 or tempstring.find('<wsdl:description') != -1:
|
|
70 #servicetype = 'WSDL2.0'
|
|
71 #break
|
|
72 while tempstring != '':
|
|
73 if tempstring.find('<bindings ') != -1 or tempstring.find('<wsdl:bindings') != -1:
|
|
74 bind = tempstring.split('type')
|
|
75 bindLength = len(bind)
|
|
76 bindingtype = bind[bindLength-1]
|
|
77 break
|
|
78 tempstring = readwsdl.readline()
|
|
79 #IF the WSDL describes SOAP web services
|
|
80 if bindingtype.find('http://www.w3.org/ns/wsdl/soap') != -1:
|
|
81 #descriptionDocument.getWSDL2Methods(url,sys.argv[2])
|
|
82 print 'WSDL 1.1'
|
|
83 #If the WSDL describes REST web services
|
|
84 else:
|
|
85 descriptionDocument.getWSDLRESTMethods(url,sys.argv[2])
|
|
86 break
|
|
87 elif tempstring.find('<application') != -1 or tempstring.find('<APPLICATION') != -1:
|
|
88 #servicetype = 'REST'
|
|
89 descriptionDocument.getWADLMethods(url,sys.argv[2])
|
|
90 break
|
|
91
|
|
92 readwsdl.close()
|
|
93
|
|
94 #if(servicetype == 'REST'):
|
|
95 # descriptionDocument.getWADLMethods(url,sys.argv[2])
|
|
96 #elif (servicetype == 'SOAP'):
|
|
97 # descriptionDocument.getWSDLMethods(url,sys.argv[2])
|
|
98 #else:
|
|
99 # descriptionDocument.getWSDL2Methods(url,sys.argv[2])
|