# Send cookies in SOAP call?

**URL:** <https://www.ruby-forum.com/t/send-cookies-in-soap-call/101444>\
**Category:** Ruby\
**Created:** [August 4, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/send-cookies-in-soap-call/101444 "2006-08-04T21:28:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_McMahon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/74df32/32.png) [@Chris\_McMahon](https://www.ruby-forum.com/u/Chris_McMahon)\
**Post date:** [August 4, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/send-cookies-in-soap-call/101444/1 "2006-08-04T21:28:05Z")

</div>

cross-posted to soap4r list, sorry about that:

I have some code that creates a connection to a SOAP server like so:

```
@soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
@soap.options["protocol.http.basic_auth"] << [wsdl_url, "user",

```

“pass”]

I can create a valid cookie like so:

```
 cookie = WebAgent::Cookie.new
 cookie.name = 'NAME'
 cookie.value = 'YES'
 cookie.url = URI.parse(@@local_wsdl_url)
 cookie.domain = 'lyris.com'
 cookie.path = '?wsdl'
 puts cookie.inspect

```

=\>  
#\<WebAgent:🍪0x55e6338 @path=“?wsdl”, @domain\_orig=nil,  
@url=#\<URI::HTTP:0x2af2f38 URL:[http://localhost:82/?wsdl](http://localhost:82/?wsdl)\>, @secure=nil,  
@domain=“[lyris.com](http://lyris.com)”, @value=“YES”, @override=nil, @discard=nil,  
@use=nil, @name=“NAME”, @path\_orig=nil\>

but I can’t figure out how to send the cookie with the SOAP request.  
Say I call a function “apiVersion”. From the examples I found, I would  
expect that these lines would produce a SOAP call with a header with  
the cookie, but it does not happen:

```
@soap.streamhandler.client.cookie_manager.add(cookie)
@query = @soap.apiVersion()

```

POST / HTTP/1.1  
SOAPAction: “”  
Content-Type: text/xml; charset=utf-8  
Authorization: Basic YWRtXYZBBQG1ubw==  
User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.4 (2005-12-24) [i386-mswin32])  
Date: Fri Aug 04 10:40:32 Pacific Daylight Time 2006  
Content-Length: 407  
Host: localhost:82

and that’s all the headers I have.

Any suggestions for how to get the cookie into the SOAP call?

---

<div class="post-metadata">

**Author:** ![Chris\_McMahon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/74df32/32.png) [@Chris\_McMahon](https://www.ruby-forum.com/u/Chris_McMahon)\
**Post date:** [May 29, 2009, 2:40pm UTC](https://www.ruby-forum.com/t/send-cookies-in-soap-call/101444/2 "2009-05-29T14:40:12Z")

</div>

all you have to do is add this line to add your cookie

@soap.streamhandler.client.cookie\_manager.add cookie
