I have a service built using Preview 2 of the WCF REST starter kit, but I've run into an issue with passing around XML-styled data in the calls. Here's my request object:
[DataContract(Namespace = "")]
public class ServiceRequest
{
[DataMember]
public string ContentText { get; set; }
[DataMember]
public string ApiKey { get; set; }
}
Everything works fine until you throw '' in there. Is there a to encapsulate the ContentText property in a CDATA or something similar?
Marc Gravell has a solution here for serializing CDATA sections.
I have copied the code here for posterity.
updated: the previous example did not generate a valid schema, the XmlSchemaProviderAttribute and accompanying method will generate "xs:string" which works [more...]
VB conversion of the CDataWrapper in the accepted answer:
Above code is missing the fact that you must go past the content after you have read it. So this class as it stands won't work with a collection.
Change it to the following, and you can now hold Collections of
CDataWrapper
.Although this is an older post here are my 2¢. I addressed this issue by defining the data member as XmlElement.