Search code examples
rubycookiessavon

how to pass cookies to another Savon client


I have two savon clients, where the second needs the cookies of the first, like an authentication cookie. I have something like this, but the call of the second client fails with an error 302, probably because the cookie is not correct or not set...

client1 = Savon.client(
    wsdl: "https://example.com/Service1.asmx?WSDL"
)
response1 = client1.call(:authenticate_user, :login => login, :passwd => password)
response1_cookies = response1.http.cookies

client2 = Savon.client(
    wsdl: "https://example.com/Service2.asmx?WSDL"
)
response2 = client2.call(:get_user_info, cookies: response1_cookies)

any idea how I should get this working?

  • savon gem version 2.6.0
  • httpi gem version 2.2.4

Solution

  • Apparently, the 302 error I got was a server-side problem. The owner of the server had to reconfigure it, so nothing was wrong with my script... Happily ever after...