WCF ResponseFormat For WebGet

Posted by michael lucas on Stack Overflow See other posts from Stack Overflow or by michael lucas
Published on 2009-06-14T09:42:17Z Indexed on 2010/04/06 6:33 UTC
Read the original article Hit count: 818

Filed under:
|
|

WCF offers two options for ResponseFormat attribute in WebGet annotation in ServiceContract.

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebGet(UriTemplate = "greet/{value}", BodyStyle = WebMessageBodyStyle.Bare)]
    string GetData(string value);

    [OperationContract]
    [WebGet(UriTemplate = "foo", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    string Foo();

The options for ResponseForamt are WebMessageFormat.Json and WebMessageFormat.Xml. Is it possible to write my own web message format? I would like that when client calls foo() method he gets raw string - without json or xml wrappers.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about responseformat