0

I have a problem with WCF service. I am a client in wcf side and i want to add some header values to my wcf request, final request, is:

<soap:Envelope
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    xmlns:tem="http://tempuri.org/">
    <soap:Header
        xmlns:wsa="http://www.w3.org/2005/08/addressing">
        <wsse:Security
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Timestamp wsu:Id="TS-6F2DD34E8610CE8C601656677431004366">
                <wsu:Created>2022-07-01T12:10:31.004Z</wsu:Created>
                <wsu:Expires>2022-07-01T12:15:31.004Z</wsu:Expires>
            </wsu:Timestamp>
            <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-6F2DD34E8610CE8C601656677430928361">certificate body</wsse:BinarySecurityToken>
            <ds:Signature Id="SIG-6F2DD34E8610CE8C601656677430937365"
                xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <ec:InclusiveNamespaces PrefixList="wsa soap tem"
                            xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                        </ds:CanonicalizationMethod>
                        <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
                        <ds:Reference URI="#id-6F2DD34E8610CE8C601656677430929364">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                    <ec:InclusiveNamespaces PrefixList="soap tem"
                                        xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                                    </ds:Transform>
                                </ds:Transforms>
                                <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                                <ds:DigestValue>fvOkKSb73QCylskA10SCp2cCwC0=</ds:DigestValue>
                            </ds:Reference>
                        </ds:SignedInfo>
                        <ds:SignatureValue>signature value</ds:SignatureValue>
                        <ds:KeyInfo Id="KI-6F2DD34E8610CE8C601656677430928362">
                            <wsse:SecurityTokenReference wsu:Id="STR-6F2DD34E8610CE8C601656677430928363">
                                <wsse:Reference URI="#X509-6F2DD34E8610CE8C601656677430928361" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
                            </wsse:SecurityTokenReference>
                        </ds:KeyInfo>
                    </ds:Signature>
                </wsse:Security>
                <wsa:Action>http://tempuri.org/IWSTRM01/CheckDeal</wsa:Action>
                <wsa:To wsu:Id="id-6F2DD34E8610CE8C601656677430929364"
                    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">https://paysrvweb.otpbank.com.ua/WSTRM/WSTRM01.svc
                </wsa:To>
            </soap:Header>
        </soap:Envelope>

I tried to do this with wsHttpBinding and BasicHttpBinding but it's not worked. How can i add all this headers to my request ?

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Dima
  • 1
  • Check out this answer (here:https://stackoverflow.com/a/964461/488699). Also, try searching for similar questions before asking – Menahem Jul 04 '22 at 11:23
  • You can also try adding custom message headers to your WCF service using Inspectors & Behaviors, see [this article](https://trycatch.me/adding-custom-message-headers-to-a-wcf-service-using-inspectors-behaviors/) for steps. You can also refer to [this post](https://stackoverflow.com/a/66372122/17218587). – Lan Huang Jul 05 '22 at 09:17

0 Answers0