I have been sending encrypted data from my application to my WCF service simply using byte[] as the datatype. However, in a very small fraction of cases I see these kinds of error:
The surrogate pair (0xD8CC, 0xAF1F) is invalid. A high surrogate
character (0xD800 – 0xDBFF) must always be paired with a low surrogate
character (0xDC00 – 0xDFFF)The surrogate pair (0xD8AC, 0xE332) is invalid. A high surrogate
character (0xD800 – 0xDBFF) must always be paired with a low surrogate
characters (0xDC00-0xDFFF).The surrogate pair (0xD8CC, 0xAAE9) is invalid. A high surrogate
character (0xD800 – 0xDBFF) must always be paired with a low surrogate
characters (0xDC00-0xDFFF).Invalid high surrogate character (OxDF44). A high surrogate character
must have a value from range(OxD800 – OxDBFF)
After much head scratching, I suspects this results when the encryption results in a sequence of bytes that the WCF XML can’t handle. Is there a better way to transmit my encrypted data via WCF? Help!
I suppose the error could be happening either direction. Here’s what I have in my .svc.
public byte[] GetEncryptedResult(byte[] encryptedRequest)
{
return ....
}
Another possibility – is that this is happening not with WCF, but when I encrypted the data. The data is put into XML, encrypted, transmitted via WCF, decrypted into XML.
Can I use DataContractSerializer? Something else?
We usually convert our encrypted byte data to a base64 string before sending it across the wire.