8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/tagger/takipi_web_service.rb', line 8
def self.request(text)
client = Savon::Client.new WSDL_URL, :soap_endpoint => URL
response = client.tag do |soap|
soap.body = "<text>#{text}</text><format>TXT</format><useGuesser>true</useGuesser>"
end
response = response.to_hash
token = response[:tag_response][:tag_response][:msg]
status = (response[:tag_response][:tag_response][:status]).to_i
timeout = 60
step = 5
count = 0
loop do
break if count > timeout
if status == 1
break
elsif status == 2 or status == 3
count += 5
sleep(1)
r = client.get_status do |soap|
soap.body = "<token>#{token}</token>"
end.to_hash
status = (r[:get_status_response][:status]).to_i
end
end
result = client.get_result do |soap|
soap.body="<token>#{token}</token>"
end
response_document = result.to_hash[:get_result_response][:tag_response][:msg]
return "<xml><chunkList>#{response_document}</chunkList></xml>"
end
|