none
WCF - No header in call RRS feed

  • Question

  •  Hello,

    I'm pretty new to WCF, I need to make a call to a webservice (which is not mine). Here is the content of the WSDL file :

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions name="PlatformIntegrationConsumerTest" targetNamespace="http://socialsecurity.be/platformintegrationconsumertest/v1" xmlns="http://socialsecurity.be/platformintegrationconsumertest/v1" xmlns:err="http://socialsecurity.be/errors/v1" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <wsdl:documentation>Version 1.1</wsdl:documentation>
      <wsp:Policy wsu:Id="SAML_HOK" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <sp:AsymmetricBinding>
          <wsp:Policy>
            <sp:InitiatorToken>
              <wsp:Policy>
                <sp:SamlToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                  <wsp:Policy>
                    <sp:WssSamlV11Token10/>
                  </wsp:Policy>
                </sp:SamlToken>
              </wsp:Policy>
            </sp:InitiatorToken>
            <sp:RecipientToken>
              <wsp:Policy>
                <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never">
                  <wsp:Policy>
                    <sp:WssX509V3Token10/>
                  </wsp:Policy>
                </sp:X509Token>
              </wsp:Policy>
            </sp:RecipientToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256/>
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Lax/>
              </wsp:Policy>
            </sp:Layout>
            <sp:IncludeTimestamp/>
            <sp:ProtectTokens/>
            <sp:OnlySignEntireHeadersAndBody/>
          </wsp:Policy>
        </sp:AsymmetricBinding>
        <sp:Wss10>
          <wsp:Policy>
            <sp:MustSupportRefKeyIdentifier/>
            <sp:MustSupportRefIssuerSerial/>
          </wsp:Policy>
        </sp:Wss10>
        <sp:SignedParts>
          <sp:Body/>
        </sp:SignedParts>
      </wsp:Policy>
      <wsp:Policy wsu:Id="X509" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <sp:AsymmetricBinding>
          <wsp:Policy>
            <sp:InitiatorToken>
              <wsp:Policy>
                <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                  <wsp:Policy>
                    <sp:WssX509V3Token10/>
                  </wsp:Policy>
                </sp:X509Token>
              </wsp:Policy>
            </sp:InitiatorToken>
            <sp:RecipientToken>
              <wsp:Policy>
                <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never">
                  <wsp:Policy>
                    <sp:WssX509V3Token10/>
                  </wsp:Policy>
                </sp:X509Token>
              </wsp:Policy>
            </sp:RecipientToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256/>
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Lax/>
              </wsp:Policy>
            </sp:Layout>
            <sp:IncludeTimestamp/>
            <sp:ProtectTokens/>
            <sp:OnlySignEntireHeadersAndBody/>
          </wsp:Policy>
        </sp:AsymmetricBinding>
        <sp:Wss10>
          <wsp:Policy>
            <sp:MustSupportRefKeyIdentifier/>
            <sp:MustSupportRefIssuerSerial/>
          </wsp:Policy>
        </sp:Wss10>
        <sp:SignedParts>
          <sp:Body/>
        </sp:SignedParts>
      </wsp:Policy>
      <wsdl:types>
        <xsd:schema>
          <xsd:import namespace="http://socialsecurity.be/platformintegrationconsumertest/v1" schemaLocation="PlatformIntegration_v1.xsd"/>
          <xsd:import namespace="http://socialsecurity.be/errors/v1" schemaLocation="../../errors/v1/socsec-errors-schema-v1.xsd"/>
        </xsd:schema>
      </wsdl:types>
      <wsdl:message name="CheckConnectionRequest">
        <wsdl:part name="CheckConnectionRequest" element="CheckConnectionRequest"/>
      </wsdl:message>
      <wsdl:message name="CheckConnectionResponse">
        <wsdl:part name="CheckConnectionResponse" element="CheckConnectionResponse"/>
      </wsdl:message>
      <wsdl:message name="CheckAccessControlRequest">
        <wsdl:part name="CheckAccessControlRequest" element="CheckAccessControlRequest"/>
      </wsdl:message>
      <wsdl:message name="CheckAccessControlResponse">
        <wsdl:part name="CheckAccessControlResponse" element="CheckAccessControlResponse"/>
      </wsdl:message>
      <wsdl:message name="CheckBrokeredAccessControlRequest">
        <wsdl:part name="CheckBrokeredAccessControlRequest" element="CheckBrokeredAccessControlRequest"/>
      </wsdl:message>
      <wsdl:message name="CheckBrokeredAccessControlResponse">
        <wsdl:part name="CheckBrokeredAccessControlResponse" element="CheckBrokeredAccessControlResponse"/>
      </wsdl:message>
      <wsdl:message name="SystemError">
        <wsdl:part name="fault" element="err:SystemError"/>
      </wsdl:message>
      <wsdl:portType name="PlatformIntegrationConsumerTestPortType">
        <wsdl:operation name="checkConnection">
          <wsdl:documentation>Operation to check connectivity to the platform on transport-level, including SSL/TLS connection setup</wsdl:documentation>
          <wsdl:input message="CheckConnectionRequest"/>
          <wsdl:output message="CheckConnectionResponse"/>
          <wsdl:fault name="systemError" message="SystemError"/>
        </wsdl:operation>
        <wsdl:operation name="checkAccessControl">
          <wsdl:documentation>Operation to check conformity to the X.509 Token Profile WS-SecurityPolicy</wsdl:documentation>
          <wsdl:input message="CheckAccessControlRequest"/>
          <wsdl:output message="CheckAccessControlResponse"/>
          <wsdl:fault name="systemError" message="SystemError"/>
        </wsdl:operation>
        <wsdl:operation name="checkBrokeredAccessControl">
          <wsdl:documentation>Operation to check conformity to the SAML Token Profile WS-SecurityPolicy (Holder of Key)</wsdl:documentation>
          <wsdl:input message="CheckBrokeredAccessControlRequest"/>
          <wsdl:output message="CheckBrokeredAccessControlResponse"/>
          <wsdl:fault name="systemError" message="SystemError"/>
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="PlatformIntegrationConsumerTestSOAPBinding" type="PlatformIntegrationConsumerTestPortType">
        <soap11:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="checkConnection">
          <soap11:operation soapAction=""/>
          <wsdl:input>
            <soap11:body use="literal"/>
          </wsdl:input>
          <wsdl:output>
            <soap11:body use="literal"/>
          </wsdl:output>
          <wsdl:fault name="systemError">
            <soap11:fault name="fault" use="literal"/>
          </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="checkAccessControl">
          <wsdl:documentation>v1.1: added new operation</wsdl:documentation>
          <soap11:operation soapAction=""/>
          <wsdl:input>
            <soap11:body use="literal"/>
            <PolicyReference URI="#X509" xmlns="http://schemas.xmlsoap.org/ws/2004/09/policy"/>
          </wsdl:input>
          <wsdl:output>
            <soap11:body use="literal"/>
          </wsdl:output>
          <wsdl:fault name="systemError">
            <soap11:fault name="fault" use="literal"/>
          </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="checkBrokeredAccessControl">
          <wsdl:documentation>v1.1: added new operation</wsdl:documentation>
          <soap11:operation soapAction=""/>
          <wsdl:input>
            <soap11:body use="literal"/>
            <PolicyReference URI="#SAML_HOK" xmlns="http://schemas.xmlsoap.org/ws/2004/09/policy"/>
          </wsdl:input>
          <wsdl:output>
            <soap11:body use="literal"/>
          </wsdl:output>
          <wsdl:fault name="systemError">
            <soap11:fault name="fault" use="literal"/>
          </wsdl:fault>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="PlatformIntegrationConsumerTestService">
        <wsdl:port name="PlatformIntegrationConsumerTestSOAP11" binding="PlatformIntegrationConsumerTestSOAPBinding">
          <soap11:address location="REPLACE_WITH_ACTUAL_URL"/>
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>

    And here is what the message should look like : 

    <soapenv:Envelope> 
      <soapenv:Header> 
        <wsse:Security> 
          <wsse:BinarySecurityToken                                                  
               EncodingType="#Base64Binary" 
               ValueType="#X509v3"   
               wsu:Id="CertId">MIIMZjCCA4...==</wsse:BinarySecurityToken>   
          <wsu:Timestamp wsu:Id="Timestamp">                                  
            <wsu:Created>2011-07-06T14:55:06Z</wsu:Created> 
            <wsu:Expires>2011-07-06T14:56:06Z</wsu:Expires> 
          </wsu:Timestamp> 
          <ds:Signature>                                                      
            <ds:SignedInfo>                                                                                                                   
              <ds:CanonicalizationMethod Algorithm="xml-exc-c14n#"/>           
              <ds:SignatureMethod Algorithm="#rsa-sha1"/> 
              <ds:Reference URI="#CertId"> 
                <ds:Transforms> 
                  <ds:Transform Algorithm="xml-exc-c14n#"/> 
                </ds:Transforms> 
                <ds:DigestMethod Algorithm="xmldsig#sha1"/> 
                <ds:DigestValue>l0k0hbnk8578dYAc2POMcBLbTkY=</ds:DigestValue> 
              </ds:Reference> 
              <ds:Reference URI="#Timestamp">                            
                <ds:Transforms> 
                  <ds:Transform Algorithm="xml-exc-c14n#"/> 
                </ds:Transforms> 
                <ds:DigestMethod Algorithm="xmldsig#sha1"/> 
                <ds:DigestValue>cUI6sRLLErYal1w1wLFxSCwjoCI=</ds:DigestValue> 
              </ds:Reference> 
              <ds:Reference URI="#id"> 
                <ds:Transforms> 
                  <ds:Transform Algorithm="xml-exc-c14n#"/> 
                </ds:Transforms> 
                <ds:DigestMethod Algorithm="xmldsig#sha1"/> 
                <ds:DigestValue>bY22PjS0HPcmEHrslVdx3uDnnpU=</ds:DigestValue> 
              </ds:Reference> 
            </ds:SignedInfo> 
            <ds:SignatureValue>uYUcEhYJ8y...==</ds:SignatureValue> 
            <ds:KeyInfo Id="KeyId-5F1BFEB349E14F0ADF130996410619213">          
              <wsse:SecurityTokenReference> 
                <wsse:Reference URI="#CertId" ValueType="#X509v3"/> 
              </wsse:SecurityTokenReference> 
            </ds:KeyInfo> 
          </ds:Signature> 
        </wsse:Security> 
      </soapenv:Header> 
      <soapenv:Body wsu:Id="id">                                                      
        <pict:CheckAccessControlRequest> 
          <type:Message>Hello World</type:Message> 
          <type:Timestamp>2010-02-24T05:32:13</type:Timestamp> 
        </pict:CheckAccessControlRequest> 
      </soapenv:Body> </soapenv:Envelope>

    The problem is I don't know how to populate the header, my generated message looks like : 

    <s:Envelope xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
    <a:Action s:mustUnderstand="1"></a:Action><a:MessageID>urn:uuid:50b28916-aade-4414-8b0a-ef6612b089f7</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <CheckAccessControlRequest xmlns="http://socialsecurity.be/platformintegrationconsumertest/v1">
    <Message xmlns="http://socialsecurity.be/platformintegrationconsumertest/types/v1">Hello world</Message>
    <Timestamp xmlns="http://socialsecurity.be/platformintegrationconsumertest/types/v1">2014-04-28T13:36:29.0560204+02:00</Timestamp>
    </CheckAccessControlRequest></s:Body></s:Envelope>

    As you can see, there's nothing good in the header. 

    Any help would be appreciated.

    Thanks in advance,

    _MaD_

    Monday, April 28, 2014 1:22 PM

Answers

All replies