Thursday, 12 September 2013

How to send multiple cookies to Java WebServices from WCF Client

How to send multiple cookies to Java WebServices from WCF Client

I need to send multiple set of cookies like below to Java WebService from
WCF Client.
Set-Cookie: JSESSIONID=ABCDLhSgAceJ9bpEFSgLvi53; Path=/XXX
Set-Cookie: zz=mmm;kk=qqq;XXXX;
These two cookies I am receving from login JAVA WebService and I need to
forward these same cookies to other Java Web Service for maintaining
sessions. I have tried with following using IClientMessageInspector but
could not sent exact two cookie as shown above. I can send only one.
if (!string.IsNullOrEmpty(cookieValueFromLogin))
{
string[] cookieValues = cookieValueFromLogin.Split(new char[]
{ ',' });
for (int i = 0; i < cookieValues.Length; i++)
{
if (!string.IsNullOrEmpty(cookieValues[i]))
{
httpRequestMessage.Headers.Add("Cookie",
cookieValues[i] );
}
}
}
Please help here if anybody knows.
Thanks MP

No comments:

Post a Comment