I have a WCF endpoint that is like such:
[OperationContract]
[WebInvoke(Method = \"POST\", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = W
I have been searching for the same solution. I managed to get it working by using 'JavaScriptSerializer'. You have to set the function output to 'Stream' not 'String'.
Public Function hotel_availability(ByVal data1 As Stream) As Stream Implements IMyTestAPI.hotel_availability
....
Dim serializer As New JavaScriptSerializer()
Dim serializedResult = serializer.Serialize(a_response)
Dim json = Encoding.UTF8.GetBytes(serializedResult)
Dim a_result as New MemoryStream(json)
WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"
return a_result
You basically need a SerializableDynamic Object, so that your method will look like this:
[OperationContract]
[WebInvoke(...)]
Stream DoWork(SerializableDynamicObject items);
You can see a good guide on how to build the SerializableDynamic Object from a Dictionary here: (see Solution section). Hope this helps...
You may have better success using the Newtonsoft JSON serializer.
It is available here http://www.newtonsoft.com/json for free and is also available as a NuGet package.
I have found to be much more flexible than the stock JSON serializers.
Also, it looks like your URITemplate is empty. I haven't used the wrapped body style, but with bare body style you need the URITemplate to be populated.
Is it an option for you to change the DoWork parameter to a string, then use a Json deserializer in the method to convert it to the appropriate format?