0

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#.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
roopini n
  • 503
  • 2
  • 7
  • 29
  • Please refer to [this post](http://stackoverflow.com/questions/1976217/how-to-add-custom-soap-headers-in-wcf) – juanreyesv Feb 14 '13 at 05:42
  • @juanreyesv: nope, he's using legacy ASMX web service technology. – John Saunders Feb 15 '13 at 03:51
  • Does the service define this header? You can't just add arbitrary headers in an ASMX web service client. – John Saunders Feb 15 '13 at 03:52
  • @JohnSaunders- I guess mine it uses svc. – roopini n Feb 15 '13 at 06:33
  • @JohnSaunders- I am poor in the Web services, what i know is there is a auto generated code in the service classes in my solution. So now there is an additional parameter is added at the service part to the "Header", so i need to send this parameter from the Header through my application. How this can be done? – roopini n Feb 15 '13 at 06:36

1 Answers1

-1

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

masterlopau
  • 563
  • 1
  • 4
  • 13