How to set SOAP values inside constructor with parameters - help

Discussion in 'ASP .Net Web Services' started by JP, Jan 5, 2009.

  1. JP

    JP Guest

    Im trying to set the values for a SOAP header of a web service. The SOAP
    header iscreated by calling a class file from inside the web service: See
    below:

    //Web Service
    public RequestAccess WSAuthorization ;
    ..
    ..
    ..
    [WebMethod(Description = "Grants requests to use methods in the web service")]
    [SoapHeader("WSAuthorization", Direction = SoapHeaderDirection.Out)]
    public string SetCredentials(string UserName, string Password)
    {
    if (UserName.Trim() != "" & Password.Trim() != "")
    {
    //does not work - value should be "New Value" but header always says
    "Initial Value" when calling subsequent methods on the service

    WSAuthorization = new RequestAccess(UserName, Password);


    // This retains values beteen calls but doesnt allow me to process
    parameters before setting the SOAP header

    WSAuthorization = new RequestAccess(); }
    }


    // Class file
    public class RequestAccess : SoapHeader
    {
    public string MyToken = "";

    internal RequestAccess()
    {
    MyToken = "Initial Value";
    }

    internal RequestAccess(string WSUserName, string WSPassword)
    {
    MyToken = "New Value";
    }
    }

    If I define the SOAP header with this line MyToken is equal to "New Value"
    only within the scope of the SetCredentials method. (Its not retained between
    web methods in the service.

    All other webmethods after this report the SOAP value as "Initial Value". It
    like unless I set my values in the parameterless constructor, the values in
    the header are blank for ALL web methods after the header is created. WHY
    ??????????



    --
    JP
    ..NET Software Developer
    JP, Jan 5, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nobody
    Replies:
    1
    Views:
    524
    Venkatesh
    Apr 26, 2006
  2. Neroku
    Replies:
    8
    Views:
    1,174
    Tor Iver Wilhelmsen
    Nov 18, 2006
  3. Generic Usenet Account
    Replies:
    10
    Views:
    2,192
  4. kito
    Replies:
    2
    Views:
    400
  5. ingoweiss
    Replies:
    4
    Views:
    200
    Julian Turner
    May 12, 2006
Loading...

Share This Page