none
Error in deserializing body of request message for operation 'GetData'

    Question

  • Hi All



    I have been trying to set up a service with HttpRelayBinding. First i started with simple wcf service with basichttpbinding and it worked. And then i changed configuration to set it for basicHttpRelayBinding" with Transport layer security.



    While testing it, i am seeing following error in Fiddler:


    <s:Fault xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">Error in deserializing body of request message for operation 'GetData'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetData' and namespace 'http://services.Company.com/SimpleService'. Found node type 'Element' with name 'soapenv:Envelope' and namespace 'http://schemas.xmlsoap.org/soap/envelope/'</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"></HelpLink><InnerException><HelpLink i:nil="true"></HelpLink><InnerException i:nil="true"></InnerException><Message>OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetData' and namespace 'http://services.Company.com/SimpleService'. Found node type 'Element' with name 'soapenv:Envelope' and namespace 'http://schemas.xmlsoap.org/soap/envelope/'</Message><StackTrace>   at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(XmlDictionaryReader reader, Object[] parameters)&#xD;
       at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)</StackTrace><Type>System.Runtime.Serialization.SerializationException</Type></InnerException><Message>Error in deserializing body of request message for operation 'GetData'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetData' and namespace 'http://services.Company.com/SimpleService'. Found node type 'Element' with name 'soapenv:Envelope' and namespace 'http://schemas.xmlsoap.org/soap/envelope/'</Message><StackTrace>   at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)&#xD;
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)&#xD;
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.ServiceModel.CommunicationException</Type></ExceptionDetail></detail></s:Fault>






    Request is:
    Request Header:
    Content-Type: text/xml
    Content-Length: 318
    SOAPAction: GetData


    Request Body:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sim="http://services.Company.com/SimpleService">
       <soapenv:Header/>
       <soapenv:Body>
          <sim:GetData>
             <!--Optional:-->
             <sim:value>12</sim:value>
          </sim:GetData>
       </soapenv:Body>
    </soapenv:Envelope>




    It works,If i alter the request to this:

          <sim:GetData xmlns:sim="http://services.Company.com/SimpleService">>
             <!--Optional:-->
             <sim:value>12</sim:value>
          </sim:GetData>




    Can anybody help me why SOAP WCF Service is not taking soap envelope?



    Thanks

    Deepak Sanghi



    Deepak Sanghi Happy Biztalking.........


    Tuesday, August 27, 2013 6:20 PM

All replies

  • Hi,

    From the error "Error in deserializing body of request message for operation 'GetData'", we can see that deserialize the response message throws the errors.

    Maybe you can try to regenerate the client code with service utility to see if the error goes on.

    Also manually deserialize a sample response may be another choice. 

    Please try to refer to the following:
    #How to manually use DataContractSerializer:
    http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx .

    #How to manually use XmlSerializer:
    http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, August 28, 2013 1:37 AM
    Moderator
  • Let me clarify same service accepts SOAP Envelope with basichttpBinding, it fails only when i use basichttprelaybinding.

    I am using Fiddler and grabbed request from SOAP UI. 

    Same Service works fine in a .net client. But my end goal is to have it work in non .net client.

    Thanks

    Deepak Sanghi


    Deepak Sanghi Happy Biztalking.........

    Wednesday, August 28, 2013 3:29 AM
  • Can somebody help me on this?

    Thanks

    Deepak Sanghi


    Deepak Sanghi Happy Biztalking.........

    Friday, August 30, 2013 4:28 AM
  • Can somebody help me on this?

    Thanks

    Deepak Sanghi


    Deepak Sanghi Happy Biztalking.........

    Thursday, September 5, 2013 7:22 AM
  • Hi Deepak,

    I am having a similar problem. I have a service that uses streaming. I use MessageContracts. I am getting an error saying that the element expected is not what was found. What is interesting is that I have a Message contract name, and a Method name. The error is saying it expected an element with the name of the method, but that the element found had the name of the message contract. 

    did you ever find a solution?

    Thanks,

    Nate

    Thursday, March 6, 2014 10:53 PM