How to set SOAP values inside constructor with parameters - help

J

JP

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
??????????
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top