none
WCF pass parameter name in JSON with WebMessageBodyStyle.Bare? RRS feed

  • Question

  • Hi im new here. Well Im planning to get the request via POST and using automaticFormatSelectionEnabled="true" to accept both xml/json content types. However, there is a limitation in requesting via JSON because you cannot add a parameter (Name), e.g.  

    {"Name": {
    "timestamp": "12.00AM",
    "datatype": "XML"
      }
    }

    Because the default WebMessageBodyStyle is set to Bare. Without using "wrapped" for WebMessageBodyStyle, is there a way to override WebMessageBodyStyle for json content type only or another mechanism to accept the JSON structure mentioned above?

    Sunday, March 10, 2013 5:09 PM

Answers

  • Hi,

    >>Without using "wrapped" for WebMessageBodyStyle, is there a way to override WebMessageBodyStyle for json content type only or another mechanism to accept the JSON structure mentioned above?

    Why not use Wrapped or WrappedRequest for WebMessageBodyStyle? WebMessageBodyStyle provides four options for different scenarios.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 12, 2013 6:37 AM
    Moderator