Restful WCF Service - how to send data with illegal XML characters?
I have a RESTful WCF web service.
One of my methods has an input parameter that is a string.
Some times the data I am passing to this parameter will include content that has one or more "illegal characters" - i.e. "&". So, I replace this with &
before passing it to the web service - but it still throws an exception. The exception isn't visible, as the data never reaches the web service, but I know that it is this content that is causing the problem, as I have done several tests sending data that doesn't contain an illegal XML character, and every time it worked, b开发者_StackOverflowut any data containing "&" will fail. Am I not supposed to replace "&" with &
?
Please refer to the web method below:
[WebGet]
public MapNode AddMapNode(string nodeText)
{
return new inProcessEntities().AddMapNode(nodeText);
}
And here is an example of how I am calling it:
ExecuteWebMethod("AddMapNode?nodeText='Ben & Jerry'");
Please help on how I can fix this.
Thanks.
Chris
If & is not allowed and is causing trouble, but you REALLY need it and other possibly illegal characters, why couldn't you just base64 encode/decode the desired values when necessary?
精彩评论