1

We have to call a web service hosted by our client. We were able to add a web reference to our ASP.Net web application and use the web service. The client just sent us a text file and said we need to pass this as a cookie to get access to the web service. I ask for their help and they sent me this.

SoapHttpClientProtocol clientProxy = new T();
clientProxy.CookieContainer.Add(uri, cookie);

Is there a way to do this using a web reference? Or do I hav eto make a soap call?

Jim Kiely
  • 365
  • 2
  • 6
  • 24

1 Answers1

1

The web reference you have generated should be derived from System.Web.Services.Protocols.SoapHttpClientProtocol (for details see this link). The ancestors of this class also provide a property named CookieContainer so that you can use the following code:

webRefInstance.CookieContainer.Add(uri, cookie);
Markus
  • 20,838
  • 4
  • 31
  • 55
  • I had to use service reference instead of web reference, any way to do the same thing? Tried to use CookieContainer and it does not exist. – Jim Kiely Oct 26 '16 at 14:33
  • See this answer for details on using a CookieContainer with a service reference: http://stackoverflow.com/a/23237303/642579 – Markus Oct 26 '16 at 17:59