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.
[WebGet(UriTemplate = "bar")]
[OperationContract]
public bar GetData() {
return new bar();
}
[XmlRoot(Namespace = "")]
public class bar : IXmlSerializable {
public void WriteXml(XmlWriter writer) {
writer.WriteString("foo");
}
public XmlSchema GetSchema() {
throw new NotImplementedException();
}
public void ReadXml(XmlReader reader) {
throw new NotImplementedException();
}
}
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.