Workflow Soluiton

 View Only
  • 1.  Editing webservice header?

    Posted Feb 08, 2012 03:03 PM

    I am connecting to BlueCat's api webservices.   To get them to work you have to call a login method that returns in the header a cookie - session ID. 

    You then have to pass that session id in the header for all other methods you call.   Has anybody done anything like this using the Webservice Caller generator?  



  • 2.  RE: Editing webservice header?
    Best Answer

    Posted Feb 08, 2012 04:42 PM

    Don't think this can be done in webservice generator. However it can be done easily in C#. We had to do something very smilar to this to interface with SEP. For example:

    public static policyList GetLuPolicySettingsList(SEPUserHolder holder)
            {
                PoliciesImplService policies = InitAndLoginService<PoliciesImplService>(holder, "Policies");

                policyList oo = policies.getLuPolicySettingsList();

                TidyUp();

                return oo;
            }

            private static SessionImplService sessionService = new SessionImplService();
            
            private static T InitAndLoginService<T>(SEPUserHolder seh, string newServiceName) where T : SoapHttpClientProtocol, new()
            {
                try
                {
                    sessionService.Url = SEPServicesBaseURL + "/Session";

                    sessionService.CookieContainer = new CookieContainer();

                    sessionService.login(seh.UserName, seh.Password, seh.Domain);

                    T otherService = new T();

                    otherService.Url = String.Format("{0}/{1}", SEPServicesBaseURL, newServiceName);

                    CookieCollection cccc = sessionService.CookieContainer.GetCookies(new Uri(SEPServicesBaseURL + "/Session"));

                    otherService.CookieContainer = new CookieContainer();
                    foreach (Cookie xxx in cccc)
                    {
                        otherService.CookieContainer.Add(new Uri(SEPServicesBaseURL + "/" + newServiceName), xxx);
                    }

                    return otherService;
                }
                catch (Exception e)
                {
                    log.LogFatal(null, "Exception Occured: ", e);
                    throw new InvalidClientCreationException("Could not create the Service Client due to the following exception.", e);
                }
            }

            private static void TidyUp()
            {
                sessionService.logout();
            }



  • 3.  RE: Editing webservice header?

    Posted Feb 08, 2012 04:50 PM

    Thanks for the code example.   I figured I would have to write something.