none
WCF webHttpBinding ByteStreamMessageEncoder (IIS8.5 server 2012) RRS feed

  • Question

  • I have a WCF service.  The method is declared with "POST" method and Bare BodyStyle.  This is used for FORM SUBMIT.

            [OperationContract]
            [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]

    Service binding is webhttpBinding.   In IIS7.5 (server 2008), the code works fine.  On the .NET side, i can get Params through  Request.Params.    However, when the codes are deployed to IIS8.5 (on server 2012), i get NULL from Request.Params...

    So i did a Service Trace Viewer ... what i notice is... on IIS7.5 the message is received with "" <Encoder> 

    <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTransmitTraceRecord">
    <MessageProperties>
    <Encoder></Encoder>
    <AllowOutputBatching>False</AllowOutputBatching>
    <Via>..........</Via>
    </MessageProperties>

    However on IIS8.5, the message is received this "ByteStreamMessageEncoder" encoder.   

    <Encoder>ByteStreamMessageEncoder</Encoder>

    Same web.Config on both servers.  What drives IIS8.5 to add ByteStreamMessageEncoder to the message property ??

    Thanks !

    Wednesday, July 1, 2015 1:46 PM

Answers

  • hi mf913,
       As per this case, you can try like below :
    [OperationContract]
     [WebInvoke(Method = "POST", 
      RequestFormat = WebMessageFormat.Json, 
    ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    for more information, Click here to refer about Difference between WebMessageBodyStyle.Wrapped and WebMessageBodyStyle.Bare with corresponding code.
    Thursday, July 9, 2015 5:24 AM

All replies

  • I have a WCF service.  The method is declared with "POST" method and Bare BodyStyle.  This is used for FORM SUBMIT.

            [OperationContract]
            [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]

    Service binding is webhttpBinding.   In IIS7.5 (server 2008), the code works fine.  On the .NET side, i can get Params through  Request.Params.    However, when the codes are deployed to IIS8.5 (on server 2012), i get NULL from Request.Params...

    So i did a Service Trace Viewer ... what i notice is... on IIS7.5 the message is received with "" <Encoder> 

    <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTransmitTraceRecord">
    <MessageProperties>
    <Encoder></Encoder>
    <AllowOutputBatching>False</AllowOutputBatching>
    <Via>..........</Via>
    </MessageProperties>

    However on IIS8.5, the message is received this "ByteStreamMessageEncoder" encoder.   

    <Encoder>ByteStreamMessageEncoder</Encoder>

    Same web.Config on both servers.  What drives IIS8.5 to add ByteStreamMessageEncoder to the message property ??

    Thanks !

    Wednesday, July 1, 2015 1:47 PM
  • hi mf913,
      As per this case, You might be missed to activate "HTTP activation" for WCF services in Windows features. As far as I know it is not enabled by default when you install IIS.

    for your information,refer the following steps to activate it :

    1.Run Server Manager (on task bar and start menu)

    2.Choose the server to administer (probably local server)

    3.Scroll down to "Roles and Features" section.

    4.Choose "Add Role or Feature" from Tasks drop down

    5.On "Add Role or Feature Wizard" dialog, click down to "Features" in list of pages on the left.

    6.Expand ".Net 3.5" or ".Net 4.5", depending on what you have installed. (you can go back up to "roles" screen to add if you don't have.

    7.Under "WCF Services", check the box for "HTTP-Activation". You can also add non-http types if you know you need them (tcp, named pipes, etc).

    8.Click "Install" Button. 

    Thursday, July 2, 2015 7:18 AM
  • I checked the Server Roles....  .NET Framework 4.5 Features are "checked" (http activation).  But .NET Framework 3.5 Features is not.  

    Our website was built with .NET 4.0.    Does it "fall" back to .NET Framework 3.5 features, and since it's not checked, it's causing problem ?

    On the other hand, if our website was built with .NET 4.5, it would have been fine ?

    Thursday, July 2, 2015 12:58 PM
  • I don't think HTTP Activation is the issue..  I tried it on the 2008 server.  If I turned off HTTP Activation, the application would not work at all.  It would throw exception like

    Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, 

    The problem i'm facing is....  The ajax post (in JSON format) works.  however, when posting in "Bare" bodystyle as in FORM SUBMIT, it doesn't work... because of some ByteStreamMessageEncoder

    Thursday, July 2, 2015 2:46 PM
  • hi mf913,
       As per this case, you can try like below :
    [OperationContract]
     [WebInvoke(Method = "POST", 
      RequestFormat = WebMessageFormat.Json, 
    ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    for more information, Click here to refer about Difference between WebMessageBodyStyle.Wrapped and WebMessageBodyStyle.Bare with corresponding code.
    Thursday, July 9, 2015 5:24 AM