Results 1 to 7 of 7

Thread: Soap Header with AuthenticationHeaderFactory

  1. #1
    Join Date
    Jun 2008
    Location
    Switzerland
    Posts
    7

    Default Soap Header with AuthenticationHeaderFactory

    Hi

    I use the example provided in this thread: Spring Web Services and soap headers
    and have now a problem. In the example, the username and password for the AuthenticationSoapHeader comes from "within" the object.

    Code:
    public object GetObject()
    {
                AuthenticationSoapHeader ash = new AuthenticationSoapHeader();
                ash.Login = "user";
                ash.Password = "welcome";
                return ash;
    }
    I also can pass username and password from the config xml. that all works fine.
    But how can i pass username and password from my calling program code?

    Code:
    IApplicationContext ctx = ContextRegistry.GetContext();
    IData data = (IData)ctx.GetObject("dataService");
    // howto pass here username and password????

  2. #2
    Join Date
    Jun 2008
    Location
    Switzerland
    Posts
    7

    Default

    ups, i forgot to say:
    hope you can help me and best regards
    Clay

    sorry, its early in the morning here :-)

  3. #3
    Join Date
    Oct 2005
    Location
    Toulouse, France
    Posts
    1,409

    Default

    Hi,

    You can define a place to store your authentication infos and get them from it in the factory code.

    You can also use Thread Local Storage from Spring.

    - Bruno
    My english is as poor as my taylor is rich

  4. #4
    Join Date
    Jun 2008
    Location
    Switzerland
    Posts
    7

    Thumbs up

    Hi Bruno

    Thank you very much, works great with Thread Local Storage

    Clay

  5. #5
    Join Date
    Apr 2009
    Posts
    2

    Default

    hi can you post your solution, i need the same and dont get it
    tnks

  6. #6
    Join Date
    Jun 2008
    Location
    Switzerland
    Posts
    7

    Default

    puh, long time ago...

    on the client, I have something like this

    Code:
    Spring.Threading.CallContextStorage ccs = new Spring.Threading.CallContextStorage();
    
                Authentication.AuthenticationSoapHeader ash = (Authentication.AuthenticationSoapHeader)ccs.GetData("authenticationHeader");
                if (ash == null)
                {
                    ash = new Authentication.AuthenticationSoapHeader();
                }
    
                ash.Login = "clay";
                ash.Password = "xxxx";
                ccs.SetData("authenticationHeader", ash);
    and on the server I read it like this

    Code:
    Authentication.AuthenticationSoapHeader ash = null;
    
                // WebService environment
                if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Items.Contains("AuthenticationSoapHeader"))
                {
                    ash = (Authentication.AuthenticationSoapHeader)System.Web.HttpContext.Current.Items["AuthenticationSoapHeader"];
                }
                // Local environment
                else
                {
                    Spring.Threading.HybridContextStorage ccs = new Spring.Threading.HybridContextStorage();
                    ash = (Authentication.AuthenticationSoapHeader)ccs.GetData("authenticationHeader");
                }
    
                // no Authentication Header
                if (ash == null)
                {
                    ash = new AuthenticationSoapHeader();
                    ash.Login = "unknown";
                    ash.Password = String.Empty;
                }
    Hope that helps
    Best regards

  7. #7
    Join Date
    Apr 2009
    Posts
    2

    Default

    thanks, i will try with this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •