Add param to header in SOAP API RRS feed

  • Question

  • User305321573 posted


    I have problem to add parameter to header in soap request. What I do:

    1. At first I create Service References.
    2. Second step I run method "Login" as

    UslugaBIRzewnPublClient statGovAPI = new UslugaBIRzewnPublClient();
    var apiKey = statGovAPI.Zaloguj(ConfigurationSettings.AppSettings["statGovKey"]);

    and I received Sid number.

    3. Third step I add param to header in statGovAPI I tried make this like:

    AddressHeader header = AddressHeader.CreateAddressHeader("sid", "my-name-space", apiKey);
    var address = new EndpointAddress(new System.Uri("my-uri"), new[] { header });
    MessageHeader messageHeader = MessageHeader.CreateHeader("sid", "my-name-space", apiKey);
    statGovAPI.Endpoint.Address = address;

    and next I run next method

    var getCaptcha = statGovAPI.PobierzCaptcha();

    I see change header but the method don't response captcha. What is wrong?


    Wednesday, May 25, 2016 10:34 AM


  • User1559292362 posted

    Hi royalapps,

    I see change header but the method don't response captcha. What is wrong?

    According to your description, it seems that you want to send custom header to your service and try to retrieve captcha from your service. do it throw any exception? please try to set a breakpoint on your service method named PobierzCaptcha and debug your service.

    in addition, do you use WCF web service? if it's the case, there are some methods about custom your header.

    1. using WCF Extras

    #WCF Extras


    2. WCF message contracts


    3. implementing IClientMessageInspector

    public object BeforeSendRequest(ref Message request, IClientChannel channel)
        International intlHeader = new International();
        intlHeader.Locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
        MessageHeader header = MessageHeader.CreateHeader(WSI18N.ElementNames.International, WSI18N.NamespaceURI, intlHeader);
        return null;

    For more information, please refer to:


    Best regards,

    Cole Wu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 26, 2016 5:52 AM