Web Service Proxy Generator
Save Cookie from SOAP call and use in another SOAP call
Gravatar is a globally recognized avatar based on your email address. Save Cookie from SOAP call and use in another SOAP call
  Saso Kuzmanov
  All
  Nov 28, 2018 @ 11:53pm

When I call SOAP service (LogOn) they return cookie (I thing some session number etc)
The when I call another service (GetStatement) I need to pass that Cookie for authorization

Question is: How to read Cookie from “Logon” call with wwDotNetBridge and WebService I have made COM control in C# but your solution with wwDotNetBridge is better

Code from my COM control using Izvodi.IzvodService;

namespace Izvodi
{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [Guid("712EF7AD-F527-46C2-BD49-EA4B1CF9E5C8")]
    [ComVisible(true)]

    public class kbIzvodi

    {
        // Ova e za KB - Web Service
        AuthService.wsAuth oAuth = new AuthService.wsAuth();
        IzvodService.WSIzvod oIzvod = new IzvodService.WSIzvod();
        System.Net.CookieContainer cookies = new System.Net.CookieContainer();

        public int KbLogon(string strUserName, string strPassword)
        {
            string refStr = "";
            int logonStatus = 0;

            oAuth.Url = "https://www.banka.com.mk/webservisi/wsAuth.asmx";
           oAuth.CookieContainer = cookies;

         try
            {
                logonStatus = oAuth.LogOn(strUserName, strPassword, ref refStr);
            }
            catch (Exception ex)
            {
                return -1;
            }
            if (logonStatus != 1)
            {
                oAuth.CookieContainer = cookies;
                oAuth.LogOff(ref refStr);
                return -1;
            }
            return logonStatus;
        }

        public int KbLogoff()
        {
            string refStr = "";
            oAuth.CookieContainer = cookies;
            oAuth.LogOff(ref refStr);
            return 1;
        }

        public string GetIzvod(string strZiroSmetka,string DatIzvod)
        {
            string XmlTable = "";
            String dIzvod;   // Den.Mesec.Godina  24.01.1973 format
            dIzvod = string.Format("{0:dd.MM.yyyy}", DatIzvod);

            StatementResult mySr;

            try
            {
oIzvod.CookieContainer = cookies;

                oIzvod.Url = "https://www.banka.com.mk/webservisi/WSIzvod.asmx";
                mySr = oIzvod.GetStatement(strZiroSmetka, dIzvod);
            }

            catch (Exception ex)
            {
                return "";
            }
            if (mySr.intResult != 10)
            {
                return "";
                // return "ERROR-"+mySr.intResult.ToString();
            }

            StringWriter sw = new StringWriter();
            mySr.Result.Tables[1].WriteXml(sw,System.Data.XmlWriteMode.WriteSchema);
            XmlTable = sw.ToString();
            return XmlTable;
        }
    }
}

 

 
Gravatar is a globally recognized avatar based on your email address. re: Save Cookie from SOAP call and use in another SOAP call
  Rick Strahl
  Saso Kuzmanov
  Nov 29, 2018 @ 01:23pm

That's pretty strange that a SOAP Web Service would use cookies to pass auth tokens or other data around - after all you are already posting a payload on each request, why are they doing this which is pretty silly.

Regardless - the way the cookie container works is that you it gets set with the result cookie and you then hold on to the container and send it on the next request. You can do the same thing with the Web Service proxy which is just a wrapper around the actual core item.

However, since it looks like you already have all the C# code to make the call, I would just call those C# methods directly with wwDotnetBridge. In your code you need to capture the cookie container returned from the auth request, then pass that on the subsequent request(s).

+++ Rick ---

© 1996-2018