I'm building a SOAP server for a rails project we have here.
I'm using actionwebservice to achieve this.

Inside the logic for one of the SOAP methods I need to read
the IP address of the requesting client.

For a regular rails controller we've been using this
construct, which works nicely
--------------------------------------------
tmp_ip = request.env["HTTP_X_FORWARDED_FOR"]
if(tmp_ip =~ /(\d+\.\d+\.\d+\.\d+)$/)
tmp_ip = $1;
else
tmp_ip = request.remote_ip
end
--------------------------------------------

But if I put that in either my webservice method or my webservice
controller I just get this error: "undefined local variable or
method `request' for PsipredApiController:Class"

Here's the controller:
--------------------------------------
class PsipredApiController < ApplicationController
web_service_dispatching_mode :delegated

@tmp_ip = request.env["HTTP_X_FORWARDED_FOR"]
if(@tmp_ip =~ /(\d+\.\d+\.\d+\.\d+)$/)
@tmp_ip = $1;
else
@tmp_ip = request.remote_ip
end

web_service :api_disopred, ApiDisopredService.new
web_service_scaffold :invoke
end
--------------------------------------

Here's the API defs
-------------------------------------
class ApiDisopred < ActionWebService::API::Base

api_method :submit, :expects => [{:sequence=>:string},
{:email=>:string},{:name=>:string}, {:fpr => :string}, {:psiblast => :string},
{:psipred => :string}], :returns => [SubmitMessage]

api_method :results, :expects => [{:job_id=>:string}], :returns => [:string]

end
-------------------------------------

and here's the methods
-------------------------------------
class ApiDisopredService < ActionWebService::Base
web_service_api ApiDisopred

def submit(sequence, email, name, fpr, psiblast, psipred)
[A GREAT DEAL OF LOGIC THAT WORKS]
results = SubmitMessage.new
results.message = @message
results.job_id = @job.id
results.state = @state
return results
end

end
---------------------------------------

I hope someone can suggest a fix.

Thanks,
Daniel


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 7, '11 at 11:10a
activeNov 7, '11 at 11:10a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Daniel Buchan: 1 post

People

Translate

site design / logo © 2021 Grokbase