Skip to main content

Posts

Showing posts from September, 2011

Use fastJSON with WCF (C#)

To use fastJson Serializer with WCF Web Service: Within a Web Site or App Project (VS), Add AjaxService Add: Method: Get, Use: Only to retrieve Data [ OperationContract ] [ WebGet (ResponseFormat = WebMessageFormat .Json)] public Stream TestStream( string ticker) { WebOperationContext .Current.OutgoingResponse.ContentType = "application/json" ; string jsonString= "{\"d\":{}}" ;//Here you do the serialization MemoryStream ms = new MemoryStream ( ASCIIEncoding .Default.GetBytes(jsonString)); return ms; } Method: Post, Use: Insert data / data manipulation [ OperationContract ] [ WebInvoke (Method= "POST" , ResponseFormat = WebMessageFormat .Json)] public Stream TestStream( string ticker) { WebOperationContext .Current.OutgoingResponse.ContentType = "application/json" ; string jsonString= "{\"d\":{}}" ;//Here you do the serialization MemoryStream ms = new MemoryStream ( ASCIIEncoding .Def