I have a REST web method in .NET 3.5:
[OperationContract]
[WebInvoke(UriTemplate = "", Method = Verbs.Get)]
public string GetBar()
{
return "foo";
}
The response gets formatted as <string>foo</string> while I would prefer <bar>foo</bar> instead. Does anyone know how to do that? I feel I am missing something obvious.
When returning XML from a WCF service you usually use one of the serializers, either the DataContractSerializer or the XmlSerializer. I was not able to get the DataContractSerializer to return what you are looking for but here is one way that works with the XmlSerializer.
Eventually I just gave up trying to get the serializers to do what I wanted and just started returning “stream” from my contracts and doing the XML generation myself.