module CannedSoap::Web
Handle all the communication to the service
Public Instance Methods
Send Http get rquest to a url and return his result via HTTPI
Params:
url
-
the url to send the request to
headers
-
hash that keeps the headers that need to be send to the service
# File lib/canned_soap/web/web_request_handler.rb, line 10 def get_web_response(url,headers) request = HTTPI::Request.new(url) request.headers = headers response = HTTPI.get(request) response end
Send http request to the service Params:
url
-
the url to send the request to
headers
-
hash that keeps the headers that need to be send to the service
body
-
the body of the HTTP request
args
-
metadata that indicate wich autountication to use
# File lib/canned_soap/web/web_request_handler.rb, line 25 def send_message_to_wcf(url,headers,body,*args) request = HTTPI::Request.new(url) request.headers = headers request.body = body #TODO: change to user self.send('use_'+) case args.first when SecurityProtocol::NTLM use_ntlm(request,*args) when SecurityProtocol::GGS_API use_kerberos(request) when SecurityProtocol::BASIC use_basic(request,*args) when SecurityProtocol::DIGEST use_digest(request,*args) end response = HTTPI.post(request) response end
Private Instance Methods
Use basic auth in the request Params:
request
-
HTTPI::Request
request args
-
keep the data that need to be uses for the basic auth
# File lib/canned_soap/web/web_request_handler.rb, line 71 def use_basic(request,*args) user = args[1] password = args[2] request.auth.basic(user,password) end
Use digest auth in the request Params:
request
-
HTTPI::Request
request args
-
keep the data that need to be uses for the digest auth
# File lib/canned_soap/web/web_request_handler.rb, line 82 def use_digest(request,*args) user = args[1] password = args[2] request.auth.digest(user,password) end
Use kerberos auth in the request Params:
request
-
HTTPI::Request
request
# File lib/canned_soap/web/web_request_handler.rb, line 63 def use_kerberos(request) request.auth.gssnegotiate end
Use ntlm auth in the request Params:
request
-
HTTPI::Request
request args
-
keep the data that need to be uses for the NTLM auth
# File lib/canned_soap/web/web_request_handler.rb, line 51 def use_ntlm(request,*args) # the first is the security name user = args[1] password = args[2] domain = args[3] request.auth.ntlm(user,password,domain)# if request.auth.ntlm? end