Consuming .net web service using rails - actionwebservice

Hi,

Environment : Rails v-1.2.3, Ruby v-1.8.6

I am trying to access the .net web services using rails app. But I am
not able to get the response.

Here are my code,

To create the api controller for define the method of .net web service
app/apis/hello_world_api.rb

class HelloWorldApi < ActionWebService::API::Base
api_method :HelloWorld,
:expects => [{:fname=>:string},{:lname=>:string}],
:returns => [:string]
end

My controller is,

class WebServiceAccessController < ApplicationController
web_client_api :hello_world, :soap,
http://10.1.12.96/satya/service1.asmx?WSDL”,
:namespace=>“http://tempuri.org/”,
:driver_options=>{:default_encodingstyle =>
SOAP::EncodingStyle::ASPDotNetHandler::Namespace }

def access
params = {‘fname’ => ‘sathiyaraj’,
‘lname’ => ‘gurusamy’
}
@delivered = hello_world.HelloWorld(params)
puts @delivered.inspect
end
end

I am running webrick server and put the below url in browser,
http://localhost:3004/web_service_access/access

Then I get below error,

HTTPClient::ReceiveTimeoutError (execution expired):
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:43:in
parse_header' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:131:in timeout’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:852:in
parse_header' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:835:in read_header’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:652:in
get_header' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1114:in do_get_header’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1063:in
do_get_block' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:869:in do_request’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:956:in
protect_keep_alive_disconnected' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:868:in do_request’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:756:in
request' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:666:in post’
C:/Ruby/lib/ruby/1.8/soap/streamHandler.rb:170:in send_post' C:/Ruby/lib/ruby/1.8/soap/streamHandler.rb:109:in send’
C:/Ruby/lib/ruby/1.8/soap/rpc/proxy.rb:170:in route' C:/Ruby/lib/ruby/1.8/soap/rpc/proxy.rb:141:in call’
C:/Ruby/lib/ruby/1.8/soap/rpc/driver.rb:178:in call' C:/Ruby/lib/ruby/1.8/soap/rpc/driver.rb:232:in HelloWorld’
C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/soap_client.rb:63:in
send' C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/soap_client.rb:63:in perform_invocation’
C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/base.rb:15:in
method_missing' /app/controllers/web_service_access_controller.rb:8:in access’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in
send' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in perform_action_without_filters’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in
call_filter' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in perform_action_without_benchmark’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' C:/Ruby/lib/ruby/1.8/benchmark.rb:293:in measure’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in perform_action’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
send' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in process_without_filters’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in
process_without_session_management_support' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in process’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in
process' C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in dispatch’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/lib/mongrel/rails.rb:76:in
process' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/../lib/mongrel/rails.rb:74:in synchronize’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/lib/mongrel/rails.rb:74:in
process' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in process_client’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in
each' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in process_client’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
run' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in initialize’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
new' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
initialize' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in new’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
run' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:282:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:281:in
each' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:281:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mongrel_rails:128:in
run' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/command.rb:212:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mongrel_rails:281
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
load' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in load’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
new_constants_in' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in load’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in new_constants_in’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
require' C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

Rendering
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/templates/rescues/layout.rhtml
(500 Internal Error)

Please any help regarding this would be appreciated.

Thanks and Regards,
Sathiya

Any suggestion and answer for this??


Sathiya

Sathiyaraj G. wrote in post #1062502:

Hi,

Environment : Rails v-1.2.3, Ruby v-1.8.6

I am trying to access the .net web services using rails app. But I am
not able to get the response.

Here are my code,

To create the api controller for define the method of .net web service
app/apis/hello_world_api.rb

class HelloWorldApi < ActionWebService::API::Base
api_method :HelloWorld,
:expects => [{:fname=>:string},{:lname=>:string}],
:returns => [:string]
end

My controller is,

class WebServiceAccessController < ApplicationController
web_client_api :hello_world, :soap,
http://10.1.12.96/satya/service1.asmx?WSDL”,
:namespace=>“http://tempuri.org/”,
:driver_options=>{:default_encodingstyle =>
SOAP::EncodingStyle::ASPDotNetHandler::Namespace }

def access
params = {‘fname’ => ‘sathiyaraj’,
‘lname’ => ‘gurusamy’
}
@delivered = hello_world.HelloWorld(params)
puts @delivered.inspect
end
end

I am running webrick server and put the below url in browser,
http://localhost:3004/web_service_access/access

Then I get below error,

HTTPClient::ReceiveTimeoutError (execution expired):

C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:43:in

`parse_header’

C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:131:in

`timeout’

C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:852:in

`parse_header’

C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:835:in

`read_header’

C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:652:in

get_header' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1114:in do_get_header’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1063:in
do_get_block' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:869:in do_request’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:956:in
protect_keep_alive_disconnected' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:868:in do_request’
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:756:in
request' C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:666:in post’
C:/Ruby/lib/ruby/1.8/soap/streamHandler.rb:170:in send_post' C:/Ruby/lib/ruby/1.8/soap/streamHandler.rb:109:in send’
C:/Ruby/lib/ruby/1.8/soap/rpc/proxy.rb:170:in route' C:/Ruby/lib/ruby/1.8/soap/rpc/proxy.rb:141:in call’
C:/Ruby/lib/ruby/1.8/soap/rpc/driver.rb:178:in call' C:/Ruby/lib/ruby/1.8/soap/rpc/driver.rb:232:in HelloWorld’

C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/soap_client.rb:63:in

`send’

C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/soap_client.rb:63:in

`perform_invocation’

C:/Ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.2.3/lib/action_web_service/client/base.rb:15:in

method_missing' /app/controllers/web_service_access_controller.rb:8:in access’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in

`send’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in

`perform_action_without_filters’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in

`call_filter’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in

`perform_action_without_benchmark’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in

perform_action_without_rescue' C:/Ruby/lib/ruby/1.8/benchmark.rb:293:in measure’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in

`perform_action_without_rescue’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in

`perform_action’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in

`send’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in

`process_without_filters’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in

`process_without_session_management_support’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in

`process’

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in

process' C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in dispatch’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/lib/mongrel/rails.rb:76:in

`process’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/lib/mongrel/rails.rb:74:in

`synchronize’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/lib/mongrel/rails.rb:74:in

`process’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in

`process_client’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in

`each’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in

`process_client’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in

`initialize’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in

`new’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in

`initialize’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in

`new’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:282:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:281:in

`each’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/configurator.rb:281:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mongrel_rails:128:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/command.rb:212:in

`run’

C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/mongrel_rails:281

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in

`load’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in

`load’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in

`new_constants_in’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in

`load’

C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60

C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in

gem_original_require' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in

`require’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in

`new_constants_in’

C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in

require' C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

Rendering

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/templates/rescues/layout.rhtml

(500 Internal Error)

Please any help regarding this would be appreciated.

Thanks and Regards,
Sathiya