我有一个连接到服务的应用程序。我想在 Soap Header 中添加一个额外的参数,我应该将它添加到哪里?
protected override WebRequest GetWebRequest(Uri uri)
{
//apptoken name to be sent instead of caller app name - 10.1
this.RequestSoapContext.Addressing.From = new Uri(ServiceConfiguration.APPTOKEN, UriKind.Relative);
WebRequest req = base.GetWebRequest(uri);
req.Headers.Add(ServiceConfiguration.HEADER_COOKIE_NAME_C, ServiceConfiguration.HEADER_COOKIE_VALUE);
req.Method = ServiceConfiguration.REQUEST_METHOD;
req.ContentType = ServiceConfiguration.REQUEST_CONTENT_TYPE;
string smsession = GetSMSessionCookie();
if (smsession != "")
{
req.Headers.Add(ServiceConfiguration.HEADER_COOKIE_NAME_C, smsession);
}
m_webRequest = req;
return req;
}
我在其中一个 Web 服务类中有这个。但我觉得这似乎是一个 Http Header。
我在另一个类中也有这个,我指定了常量。
public const string REQUEST_METHOD = "POST";
public const string REQUEST_CONTENT_TYPE = "text/xml";
public const string HEADER_SOAP_ACTION_NAME = "SOAPAction";
public const string HEADER_SOAP_ACTION_VALUE = "/";
public const string HEADER_COOKIE_VALUE = "SMCHALLENGE=YES";
public const string HEADER_APPLICATION_NAME = "APPLICATION_NAME";
public const string HEADER_APPLICATION_VALUE = "XLS";
public const string COOKIE_SMSESSION = "SMSESSION=";
public const string HEADER_COOKIE_NAME_C = "Cookie";
public const string HEADER_COOKIE_NAME_SETC = "Set-Cookie";
public const string HEADER_COOKIE_SEPARATOR = ";";
有人可以帮我如何在 SOAP REQUEST Header 中添加我自己的附加参数吗?
我正在使用 winforms .net 4.0 c#。