To use fastJson Serializer with WCF Web Service:
[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;
}
[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.Default.GetBytes(jsonString));
return ms;
}
- Within a Web Site or App Project (VS), Add AjaxService
- Add:
- Method: Get, Use: Only to retrieve Data
[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
[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.Default.GetBytes(jsonString));
return ms;
}
Comments
Post a Comment