Given a web method like this :
[WebMethod]
public string DoEcho(string data)
{
return "echoed <" + data + ">";
}
When this method is called from the client, eg :
string res = service1.DoEcho("\x01");
you get a : System.Xml.XmlException, with message like :
"hexadecimal value 0x01, is an invalid character."
I understand this by design, since chars like 0x01
are not valid XML chars, according to docs like :
http://www.w3.org/TR/REC-xml/#NT-Char
However, just say I still really need to send these sort
of strings around. One possibility is to convert the string
to a byte array, then send as byte array (base64
encoded string by dotent). However, this
seems inefficient.
Has anyone else had this requirement, and found a
good workaround ?
TIA,
Stephen