0

Interface IService

 <OperationContract(Action:="urn:abc")> _
 <WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, Method:="POST")>
 Function abc(a as String) As String

Method Service

Public Function abc(a as String) As String Implements IService.abc
       'Method
    End Function

Web.Config

<services>
      <service name="Service.IServices">
        <endpoint address="" binding="customBinding" contract="Service.IServices" bindingConfiguration="httpSoap12">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <customBinding>
    <binding name="httpSoap12">
      <textMessageEncoding messageVersion="Soap12" />
      <httpTransport />
    </binding>
  </customBinding>

Request Message

POST http://localhost/Services.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="urn:abc"
Content-Length: 1230
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Error

Error in deserializing body of request message for operation 'abc'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'abc' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'typ:abc' and namespace 'http://tem.com/'

I facing this error few days, and I find many solution on web but still facing this error. Got any advice or solution to solve it? Isn't I no yet get the action?

askingPPl
  • 263
  • 3
  • 20
  • What test client are you using? – Jocke Oct 17 '13 at 10:27
  • And why don't you use a UriTemplate? – Jocke Oct 17 '13 at 10:39
  • Check out this blog post: http://social.msdn.microsoft.com/Forums/vstudio/en-US/dc3344df-f0e9-4cd3-9d5a-81f4cd6de136/why-does-bodystyle-webmessagebodystylebare-removes-the-user-defined-namespace-for-the-root?forum=wcf – Jocke Oct 17 '13 at 10:44

2 Answers2

1

My advise is to convert your string to a byte array and Encode/Decode it on each side. I get tired of running into strange issues like this in my web services so now EVERY method on my web services take in byte arrays and return byte array. It does not add any time to them, since the web services eventually do this anyway.

See this post for examples net-string-to-byte-array

Community
  • 1
  • 1
Steve
  • 5,585
  • 2
  • 18
  • 32
0

I am not sure if this will help, but I had a similar error with a service where I wanted to stream data, instead of buffer it. Some may not know, but changing the transfer mode to streaming requires a certain design pattern - otherwise, it will just revert to buffering. So, I followed the design pattern, and ran into the same error. I solved it. Here is the post with my answer:

Streaming: Message Contract Error

Community
  • 1
  • 1
essedbl
  • 520
  • 1
  • 7
  • 19