tags:

views:

26

answers:

2

I have code something like the following:

<OperationContract()>
<Description("")>
<WebGet(Bodystyle:=WebMessageBodyStyle.Bare, UriTemplate:="TestConnection")>
Function TestConnection() As String


Public Function TestConnection() As String Implements ITestSvc.TestConnection
    WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"
    Return "Connection Success"
End Function

But it returns is <string xmlns='...'>Connection Success</string>

How can I have only "Connection Success" to be returned without XML wrapper. I know that we can do something with MessageEncoder. But, I want to have it available at operation level (certain operations need XML/JSON wrappers and certain operations don't).

Can anyone help me on this?

A: 

WCF REST service returns XML or JSON not a plain text.

Ladislav Mrnka
I know that. But, I guess there should be a way to accomplish what I am need for. But, unable to figure that out.
A: 

The answer is here http://stackoverflow.com/questions/992533/wcf-responseformat-for-webget (and it worked for me)