开发者

WCF error when sending special characters

开发者 https://www.devze.com 2023-03-16 08:22 出处:网络
I have a simple WCF service that will analyse a raw text extracted from a .pdf or a .doc file. 99% of the uploaded string are ok but in some cases, the server will raise a Bad Request exception

I have a simple WCF service that will analyse a raw text extracted from a .pdf or a .doc file.

99% of the uploaded string are ok but in some cases, the server will raise a Bad Request exception

The remote server returned an unexpected response: (400) Bad Request.

After investigating the faulty text, I did find out that the problem is related to a Form Feed character (ascii / unicode #12).

The easy solution is to remove those characters before uploading the s开发者_如何学Pythontring but in my case, I don't have the control over every clients that will consume the WCF service.

So, is there any server side alternative that would allow me to upload this special characters (and any other character that might lead the the same exception)?


If you are using basic or wshttp binding, safe way to pass that kind of strings around is to use base64 encoding on both client and server side. In your case i would suggest using byte[] which in terms will be serialized into a base64 string.

Unfortunately there is no way to handle bad requests on the server side, that i know about.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号