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