tags:

views:

91

answers:

2

Hi,

i got a webservice and want to return this "string" as a bare string, without the extra serialization by WCF, because it's already serialized... how do i do it?

    [OperationContract]
    [FaultContract(typeof(Exception))]
    [WebGet(ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json)]
    string Get_Json();
A: 

I have found the solution for this on this page. The following should work:

[OperationContract]
public Stream Get_Json() {
    return new MemoryStream(Encoding.UTF8.GetBytes("This is a string"));
}
Lukas Cenovsky
A: 

add a servic/operation behavior that overrides the serializer.. and do nothing in it... just return the result as is

Chen Kinnrot