Создайте класс для вашего мыльного заголовка, как обычно.
public class AuthHeader : SoapHeader
{
public string CompanyID;
public string Username;
public string Password;
}
Тогда в вашем обычном классе была ссылка.
public class MyClass : WebService
{
public readonly AuthHeader authHeader;
[SoapHeader("authHeader", Direction = SoapHeaderDirection.In)]
[WebMethod(CacheDuration = 20
, EnableSession = true
, Description = "Find stuff now."
, MessageName = "FindStuff")]
[ScriptMethod(UseHttpGet = false
, ResponseFormat = ResponseFormat.Xml
, XmlSerializeString = true)]
public MyResponseClass FindStuff(string searchString)
{
MyResponseClass myResponseClass = new MyResponseClass();
if (authHeader.Username == "myUser" &&
authHeader.Password == "myPass" &&
authHeader.CompanyID == "BobsTire")
{
....
myResponseClass = ....
}
return myResponseClass;
}
}