simplews 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +4 -0
- data/TestWS.wsdl +112 -0
- data/lib/helper.rb +0 -0
- data/lib/simplews/asynchronous.rb +171 -0
- data/lib/simplews/version.rb +1 -1
- metadata +5 -1
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -3,9 +3,12 @@ Manifest.txt
|
|
3
3
|
PostInstall.txt
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
|
+
TestWS.wsdl
|
6
7
|
config/hoe.rb
|
7
8
|
config/requirements.rb
|
9
|
+
lib/helper.rb
|
8
10
|
lib/simplews.rb
|
11
|
+
lib/simplews/asynchronous.rb
|
9
12
|
lib/simplews/version.rb
|
10
13
|
script/console
|
11
14
|
script/destroy
|
@@ -15,6 +18,7 @@ setup.rb
|
|
15
18
|
tasks/deployment.rake
|
16
19
|
tasks/environment.rake
|
17
20
|
tasks/website.rake
|
21
|
+
test/simplews/test_asynchronous.rb
|
18
22
|
test/test_helper.rb
|
19
23
|
test/test_simplews.rb
|
20
24
|
website/index.html
|
data/TestWS.wsdl
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
3
|
+
xmlns:tns="TestWS-NS"
|
4
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
7
|
+
xmlns:si="http://soapinterop.org/xsd"
|
8
|
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
9
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
10
|
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
11
|
+
targetNamespace="TestWS-NS">
|
12
|
+
|
13
|
+
|
14
|
+
<types>
|
15
|
+
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
16
|
+
targetNamespace="TestWS-NS"
|
17
|
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
18
|
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
|
19
|
+
<complexType name="ArrayOfString">
|
20
|
+
<complexContent>
|
21
|
+
<restriction base="soapenc:Array">
|
22
|
+
<attribute ref="soapenc:arrayType"
|
23
|
+
wsdl:arrayType="string[]"/>
|
24
|
+
</restriction>
|
25
|
+
</complexContent>
|
26
|
+
</complexType>
|
27
|
+
</schema>
|
28
|
+
</types>
|
29
|
+
|
30
|
+
<message name="wsdlRequest">
|
31
|
+
</message>
|
32
|
+
|
33
|
+
<message name="wsdlResponse">
|
34
|
+
<part type="xsd:string" name="return"/>
|
35
|
+
</message>
|
36
|
+
|
37
|
+
<message name="hiRequest">
|
38
|
+
<part type="xsd:string" name="name"/>
|
39
|
+
</message>
|
40
|
+
|
41
|
+
<message name="hiResponse">
|
42
|
+
<part type="xsd:string" name="return"/>
|
43
|
+
</message>
|
44
|
+
|
45
|
+
<message name="byeRequest">
|
46
|
+
<part type="xsd:string" name="name"/>
|
47
|
+
</message>
|
48
|
+
|
49
|
+
<message name="byeResponse">
|
50
|
+
<part type="xsd:string" name="return"/>
|
51
|
+
</message>
|
52
|
+
|
53
|
+
<portType name="TestWS">
|
54
|
+
<operation name="wsdl">
|
55
|
+
<input message="wsdlRequest"/>
|
56
|
+
<output message="wsdlResponse"/>
|
57
|
+
</operation>
|
58
|
+
|
59
|
+
<operation name="hi">
|
60
|
+
<input message="hiRequest"/>
|
61
|
+
<output message="hiResponse"/>
|
62
|
+
</operation>
|
63
|
+
|
64
|
+
<operation name="bye">
|
65
|
+
<input message="byeRequest"/>
|
66
|
+
<output message="byeResponse"/>
|
67
|
+
</operation>
|
68
|
+
|
69
|
+
</portType>
|
70
|
+
|
71
|
+
<binding name="TestWSBinding" type="tns:TestWS">
|
72
|
+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
|
73
|
+
<operation name="wsdl">
|
74
|
+
<soap:operation soapAction="urn:TestWS#wsdl" style="rpc"/>
|
75
|
+
<input>
|
76
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
77
|
+
</input>
|
78
|
+
<output>
|
79
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
80
|
+
</output>
|
81
|
+
</operation>
|
82
|
+
|
83
|
+
<operation name="hi">
|
84
|
+
<soap:operation soapAction="urn:TestWS#hi" style="rpc"/>
|
85
|
+
<input>
|
86
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
87
|
+
</input>
|
88
|
+
<output>
|
89
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
90
|
+
</output>
|
91
|
+
</operation>
|
92
|
+
|
93
|
+
<operation name="bye">
|
94
|
+
<soap:operation soapAction="urn:TestWS#bye" style="rpc"/>
|
95
|
+
<input>
|
96
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
97
|
+
</input>
|
98
|
+
<output>
|
99
|
+
<soap:body namespace="urn:TestWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
|
100
|
+
</output>
|
101
|
+
</operation>
|
102
|
+
|
103
|
+
</binding>
|
104
|
+
<service name="TestWS">
|
105
|
+
<documentation>Greeting Services</documentation>
|
106
|
+
|
107
|
+
<port name="TestWS" binding="tns:TestWSBinding">
|
108
|
+
<soap:address location="http://localhost:1984"/>
|
109
|
+
</port>
|
110
|
+
</service>
|
111
|
+
|
112
|
+
</definitions>
|
data/lib/helper.rb
ADDED
File without changes
|
@@ -0,0 +1,171 @@
|
|
1
|
+
class SimpleWS::Asynchronous < SimpleWS
|
2
|
+
|
3
|
+
class JobNotFound < Exception; end
|
4
|
+
class JobAborted < Exception; end
|
5
|
+
|
6
|
+
|
7
|
+
class Job
|
8
|
+
|
9
|
+
@@jobs = {}
|
10
|
+
attr_reader :status, :messages, :name
|
11
|
+
|
12
|
+
def self.random_name(s="", num=20)
|
13
|
+
num.times{
|
14
|
+
r = rand
|
15
|
+
if r < 0.3
|
16
|
+
s << (rand * 10).to_i.to_s
|
17
|
+
elsif r < 0.6
|
18
|
+
s << (rand * (?z - ?a) + ?a).to_i.chr
|
19
|
+
else
|
20
|
+
s << (rand * (?Z - ?A) + ?A).to_i.chr
|
21
|
+
end
|
22
|
+
}
|
23
|
+
s.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.make_name(name)
|
27
|
+
|
28
|
+
name = Job::random_name("job-") if name == ""
|
29
|
+
|
30
|
+
taken = @@jobs.keys.select{|n| n =~ /^#{ name }(-\d+)?$/}
|
31
|
+
if taken.any?
|
32
|
+
last = taken.sort.last
|
33
|
+
if last == name
|
34
|
+
return name + '-1'
|
35
|
+
else
|
36
|
+
num = last.match(/-(\d+)$/)[1]
|
37
|
+
return name + '-' + (num.to_i + 1).to_s
|
38
|
+
end
|
39
|
+
else
|
40
|
+
return name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.status(name)
|
45
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
46
|
+
@@jobs[name].status
|
47
|
+
end
|
48
|
+
def self.messages(name)
|
49
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
50
|
+
@@jobs[name].messages
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.done?(name)
|
54
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
55
|
+
@@jobs[name].done?
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.error?(name)
|
59
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
60
|
+
@@jobs[name].error?
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.abort(name)
|
64
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
65
|
+
@@jobs[name].abort
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.aborted?(name)
|
69
|
+
raise JobNotFound, "Job with name '#{ name }' was not found" if @@jobs[name].nil?
|
70
|
+
@@jobs[name].aborted?
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def self.start(name,&block)
|
75
|
+
job = Job.new(name, &block)
|
76
|
+
@@jobs[job.name] = job
|
77
|
+
job.name
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def initialize(name, &block)
|
82
|
+
@status = ''
|
83
|
+
@messages = []
|
84
|
+
@name = Job::make_name(name)
|
85
|
+
|
86
|
+
@thread = Thread.new{
|
87
|
+
begin
|
88
|
+
instance_eval(&block)
|
89
|
+
step(:done)
|
90
|
+
|
91
|
+
rescue JobAborted
|
92
|
+
step(:aborted, $!.message)
|
93
|
+
end
|
94
|
+
}
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def step(status, message="")
|
99
|
+
@status = status
|
100
|
+
@messages << message if message != ""
|
101
|
+
end
|
102
|
+
|
103
|
+
def status
|
104
|
+
@status.to_s
|
105
|
+
end
|
106
|
+
|
107
|
+
def done?
|
108
|
+
@status.to_sym == :done || @status.to_sym == :error
|
109
|
+
end
|
110
|
+
|
111
|
+
def error?
|
112
|
+
@status.to_sym == :error
|
113
|
+
end
|
114
|
+
|
115
|
+
def error(message)
|
116
|
+
step(:error, message)
|
117
|
+
end
|
118
|
+
|
119
|
+
def abort
|
120
|
+
@thread.raise(JobAborted.new)
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def aborted?
|
125
|
+
@status.to_sym == :aborted
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
def status(name)
|
132
|
+
Job.status(name)
|
133
|
+
end
|
134
|
+
|
135
|
+
def abort(name)
|
136
|
+
Job.abort(name)
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
def done(name)
|
141
|
+
Job.done?(name)
|
142
|
+
end
|
143
|
+
|
144
|
+
def aborted(name)
|
145
|
+
Job.done?(name)
|
146
|
+
end
|
147
|
+
|
148
|
+
def error(name)
|
149
|
+
Job.error?(name)
|
150
|
+
end
|
151
|
+
|
152
|
+
def messages(name)
|
153
|
+
Job.messages(name)
|
154
|
+
end
|
155
|
+
|
156
|
+
def initialize(*args)
|
157
|
+
super(*args)
|
158
|
+
|
159
|
+
serve :abort, %(name), :name => :string
|
160
|
+
|
161
|
+
serve :messages, %(name), :name => :string, :return => :string
|
162
|
+
|
163
|
+
serve :status, %(name), :name => :string, :return => :string
|
164
|
+
serve :done, %(name), :name => :string, :return => :boolean
|
165
|
+
serve :error, %(name), :name => :string, :return => :boolean
|
166
|
+
serve :aborted, %(name), :name => :string, :return => :boolean
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
end
|
data/lib/simplews/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplews
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
@@ -40,9 +40,12 @@ files:
|
|
40
40
|
- PostInstall.txt
|
41
41
|
- README.rdoc
|
42
42
|
- Rakefile
|
43
|
+
- TestWS.wsdl
|
43
44
|
- config/hoe.rb
|
44
45
|
- config/requirements.rb
|
46
|
+
- lib/helper.rb
|
45
47
|
- lib/simplews.rb
|
48
|
+
- lib/simplews/asynchronous.rb
|
46
49
|
- lib/simplews/version.rb
|
47
50
|
- script/console
|
48
51
|
- script/destroy
|
@@ -52,6 +55,7 @@ files:
|
|
52
55
|
- tasks/deployment.rake
|
53
56
|
- tasks/environment.rake
|
54
57
|
- tasks/website.rake
|
58
|
+
- test/simplews/test_asynchronous.rb
|
55
59
|
- test/test_helper.rb
|
56
60
|
- test/test_simplews.rb
|
57
61
|
- website/index.html
|