问题描述:

I have an application that connects to a service. I want to add an additional parameter to the Soap Header, where should i exactly add this to?

 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;

}

i have this in one of the web service class. But i feel this seems to be a Http Header.

I also have this in another class i have the constants specified.

 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 = ";";

Can someone help me how to add an additional parameter of my own in the SOAP REQUEST Header?

I am using winforms .net 4.0 c#.

网友答案:

I'm not sure If I get your question right but you can add custom header by typing req.Headers.Add("customheadername","value");

相关阅读:
Top