我需要编写 .Net (C#) 一个从 SAP 端使用的 Web 服务。我编写了 c# 网络服务,但问题是需要添加 HTTP 请求标头。实际上我不知道如何将 HTTP 请求标头添加到 Web 服务?我添加了 SOAP 标头,但 SAP 端需要 HTTP 请求标头。
示例代码
public class TestService : System.Web.Services.WebService
{
public class AuthSoapHeader : SoapHeader
{
public AuthSoapHeader() { }
public string Username = string.Empty;
public string Password = string.Empty;
}
[WebMethod]
[SoapHeader("AuthHeader")]
public List<Response> Testmethod(TestClass testData)
{
if ( AuthHeader.Username == "testuser" && AuthHeader.Password == "testpawd")
{
}
}
}
请问有人知道怎么做吗?
谢谢