Missing action in content-type of WCF SOAP call HTTP header

11,434

I think your problem is to do with:

Next I tweaked my app.config a little, to force it to use soap1.2

You are already specifying WSHttpBinding when you create the client in code, and this by default will send soap12 requests.

I think your tweaking of the binding (adding the custom binding) is somehow overriding the default behavior of the wsHttpBinding, which is to put the soap action into the content-type header value.

What happens if you use the generated config file without tweaking?

EDIT

My new theory is this - the way you're creating your client in code is causing WCF to ignore the binding defined in the config file.

You should create the binding instance by passing in the name of the client binding as defined in the config file eg:

var serviceBinding = new WSHttpBinding("vz801802Soap12");

Either that or set the Binding.MessageVersion property in code too.

EDIT

What I don't understand then is why you are initialising the client in code by passing in a binding. Can you just create the client and pass in the name of the client endpoint in the config file? There should be no reason to start creating stuff in code as all necessary stuff should have been put into the config by visual studio when you added the service reference

Share:
11,434
Marco Voorwinden
Author by

Marco Voorwinden

Updated on June 04, 2022

Comments

  • Marco Voorwinden
    Marco Voorwinden almost 2 years

    I have been investigating for several days why my SOAP request isn't correct according to my vendor, and how I can change it.

    I followed the steps below to create my SOAP Client:

    • Added the service reference to my project. The wsdl of the service is:
    
    
        <?xml version="1.0" encoding="utf-8"?>
        <wsdl:definitions name="vz801802Service" targetNamespace="http://schemas.vecozo.nl/VZ801802/v1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://schemas.vecozo.nl/VZ801802/v1" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <wsp:Policy wsu:Id="vz801802Soap12_policy">
          <wsp:ExactlyOne>
           <wsp:All>
            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
             <wsp:Policy>
              <sp:TransportToken>
               <wsp:Policy>
                <sp:HttpsToken RequireClientCertificate="true"/>
               </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
               <wsp:Policy>
                <sp:Basic256/>
               </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
               <wsp:Policy>
                <sp:Strict/>
               </wsp:Policy>
              </sp:Layout>
             </wsp:Policy>
            </sp:TransportBinding>
           </wsp:All>
          </wsp:ExactlyOne>
         </wsp:Policy>
         <wsp:Policy wsu:Id="vz801802Soap11_policy">
          <wsp:ExactlyOne>
           <wsp:All>
            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
             <wsp:Policy>
              <sp:TransportToken>
               <wsp:Policy>
                <sp:HttpsToken RequireClientCertificate="true"/>
               </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
               <wsp:Policy>
                <sp:Basic256/>
               </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
               <wsp:Policy>
                <sp:Strict/>
               </wsp:Policy>
              </sp:Layout>
             </wsp:Policy>
            </sp:TransportBinding>
           </wsp:All>
          </wsp:ExactlyOne>
         </wsp:Policy>
         <wsdl:types>
          <xsd:schema targetNamespace="http://schemas.vecozo.nl/VZ801802/v1/Imports">
           <xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd0" namespace="http://schemas.vecozo.nl/VZ801802/v1"/>
           <xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
           <xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd2" namespace="http://schemas.vecozo.nl/VZ801802/v1/messages"/>
           <xsd:import schemaLocation="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc?xsd=xsd3" namespace="http://schemas.vecozo.nl/VZ801802/v1/types"/>
          </xsd:schema>
         </wsdl:types>
         <wsdl:message name="vz801802Service_Controleer_InputMessage">
          <wsdl:part name="parameters" element="tns:Controleer"/>
         </wsdl:message>
         <wsdl:message name="vz801802Service_Controleer_OutputMessage">
          <wsdl:part name="parameters" element="tns:ControleerResponse"/>
         </wsdl:message>
         <wsdl:portType name="vz801802Service">
          <wsdl:operation name="Controleer">
           <wsdl:input wsaw:Action="http://schemas.vecozo.nl/VZ801802/v1/Controleer" message="tns:vz801802Service_Controleer_InputMessage"/>
           <wsdl:output wsaw:Action="http://schemas.vecozo.nl/VZ801802/v1/Controleer/reply" message="tns:vz801802Service_Controleer_OutputMessage"/>
          </wsdl:operation>
         </wsdl:portType>
         <wsdl:binding name="vz801802Soap12" type="tns:vz801802Service">
          <wsp:PolicyReference URI="#vz801802Soap12_policy"/>
          <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
          <wsdl:operation name="Controleer">
           <soap12:operation soapAction="http://schemas.vecozo.nl/VZ801802/v1/Controleer" style="document"/>
           <wsdl:input>
            <soap12:body use="literal"/>
           </wsdl:input>
           <wsdl:output>
            <soap12:body use="literal"/>
           </wsdl:output>
          </wsdl:operation>
         </wsdl:binding>
         <wsdl:binding name="vz801802Soap11" type="tns:vz801802Service">
          <wsp:PolicyReference URI="#vz801802Soap11_policy"/>
          <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
          <wsdl:operation name="Controleer">
           <soap:operation soapAction="http://schemas.vecozo.nl/VZ801802/v1/Controleer" style="document"/>
           <wsdl:input>
            <soap:body use="literal"/>
           </wsdl:input>
           <wsdl:output>
            <soap:body use="literal"/>
           </wsdl:output>
          </wsdl:operation>
         </wsdl:binding>
         <wsdl:service name="vz801802Service">
          <wsdl:port name="vz801802Soap12" binding="tns:vz801802Soap12">
           <soap12:address location="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc"/>
          </wsdl:port>
          <wsdl:port name="vz801802Soap11" binding="tns:vz801802Soap11">
           <soap:address location="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc/soap11"/>
          </wsdl:port>
         </wsdl:service>
        </wsdl:definitions>
    
    

    This created the proxy class for me.

    • Next I tweaked my app.config a little, to force it to use soap1.2 (so I removed the soap1.1 entries, because of the problems I had)

      <?xml version="1.0"?>
      <configuration>
          <system.serviceModel>
              <bindings>
                  <customBinding>
                      <binding name="vz801802Soap12">
                          <textMessageEncoding messageVersion="Soap12" />
                          <httpsTransport requireClientCertificate="true" />
                      </binding>
                  </customBinding>
              </bindings>
              <client>
                  <endpoint address="https://acccovwebservice.vecozo.nl/v1/VZ801802.svc"
                      binding="customBinding" bindingConfiguration="vz801802Soap12"
                      contract="COV_VZ801802.vz801802Service" name="vz801802Soap12" />
              </client>
          </system.serviceModel>
      </configuration>
      

    • The code to instantiate and call the webservice is:

      WSHttpBinding serviceBinding = new WSHttpBinding(SecurityMode.Transport);
      serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
      serviceBinding.ReceiveTimeout = new TimeSpan(0, 0, 120);
      EndpointAddress endpointAddress = new EndpointAddress(Bericht.Url); COV_VZ801802.vz801802ServiceClient VZ801_Client = new COV_VZ801802.vz801802ServiceClient(serviceBinding, endpointAddress);
      if (Bericht.Certificaat != null && Bericht.Certificaat != "") { X509Certificate2 x509_2 = new X509Certificate2(Bericht.Certificaat); VZ801_Client.ClientCredentials.ClientCertificate.Certificate = x509_2; }
      COV_VZ801802.ControleerRequestType VZ801_Request = new COV_VZ801802.ControleerRequestType();
      // Here I fill request with data
      COV_VZ801802.ControleerResponseType VZ801_Reponse = VZ801_Client.Controleer(VZ801_Request);

    • When checking the message with Fiddler, I see the following:

      POST https://acccovwebservice.vecozo.nl/v1/VZ801802.svc HTTP/1.1
      Content-Type: application/soap+xml; charset=utf-8
      Host: acccovwebservice.vecozo.nl
      Content-Length: 1216
      Expect: 100-continue
      Accept-Encoding: gzip, deflate
      Connection: Keep-Alive

      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">http://schemas.vecozo.nl/VZ801802/v1/Controleer</a:Action> <a:MessageID>urn:uuid:a492c393-a93b-43df-9f0e-4e3f7116f8a2</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">https://acccovwebservice.vecozo.nl/v1/VZ801802.svc</a:To> </s:Header> <s:Body> <Controleer xmlns="http://schemas.vecozo.nl/VZ801802/v1"> <request xmlns:b="http://schemas.vecozo.nl/VZ801802/v1/messages" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <b:Zorgaanbieder i:nil="true" xmlns:c="http://schemas.vecozo.nl/VZ801802/v1/types"/> <b:Zoekopdrachten xmlns:c="http://schemas.vecozo.nl/VZ801802/v1/types"> <c:Zoekopdracht> <c:Volgnummer>0</c:Volgnummer> <c:Geboortedatum>1956-01-14</c:Geboortedatum> <c:Peildatum>2013-05-08</c:Peildatum> <c:Bsn i:nil="true"/> <c:Verzekerdenummer>FB_60585</c:Verzekerdenummer> <c:Postcode i:nil="true"/> <c:ReferentieZorgaanbieder i:nil="true"/> <c:Huisnummer i:nil="true"/> <c:Huisnummertoevoeging i:nil="true"/> </c:Zoekopdracht> </b:Zoekopdrachten> </request> </Controleer> </s:Body> </s:Envelope>

    When running the program, I get an exception, telling me:

    The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

    The vendor told me that he sees two problems in this message:

    1. There's no action defined in the content-type of the header. Content-type should be application/soap+xml;charset=UTF-8;action="http://schemas.vecozo.nl/VZ801802/v1/Controleer"
    2. Both values of MustUnderstand (in Action and To tag) should be 0 instead of 1

    I've been searching and searching all kind of places, tried custom headers, etc, etc, but I did not find a way yet to fix those issues.

    Anyone out there can help me with this??? I'm quite desperate, for I need to fix this before June 1st.

    BTW I am using .NET 4.0 BTW2 I am using Visual Studio Express 2012 for Windows Desktop to edit my project

    EDIT:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] 
        [System.ServiceModel.ServiceContractAttribute(Namespace="schemas.vecozo.nl/VZ801802/v1";, ConfigurationName="COV_VZ801802.vz801802Service")] 
        public interface vz801802Service 
        { 
            [System.ServiceModel.OperationContractAttribute(Action="schemas.vecozo.nl/VZ801802/v1/Controleer";, ReplyAction="schemas.vecozo.nl/VZ801802/v1/Controleer/reply")] 
            SOAPLib.COV_VZ801802.ControleerResponseType Controleer(SOAPLib.COV_VZ801802.ControleerRequestType request); 
        }
    
  • tom redfern
    tom redfern almost 11 years
    Can you post the regen'd app config pls?
  • Marco Voorwinden
    Marco Voorwinden almost 11 years
    When trying the client binding I get the error: No elements matching the key 'vz801802Soap12' were found in the configuration el ement collection.
  • Marco Voorwinden
    Marco Voorwinden almost 11 years
    When requesting the MessageVersion of my wsHttpBinding it gives met SAOP12 with Addressing10, so it seems to me to be correct..
  • tom redfern
    tom redfern almost 11 years
    What I don't understand then is why you are initialising the client in code by passing in a binding. Can you just create the client and pass in the name of the client endpoint in the config file? There should be no reason to start creating stuff in code as all necessary stuff should have been put into the config by visual studio when you added the service reference.
  • Marco Voorwinden
    Marco Voorwinden almost 11 years
    THANKS!!! That was the solution. It was clearly my lack of SOAP knowledge that I started programming the way I did.. Againg, thanks a bunch!