Why does WCF remove whitespace in text field when security is set to none?
wh开发者_C百科en try a simple wcf service call at client, the string data member received at service side has its whitespaces at the beginning removed if we using binding as below.
binding: <binding name="WSHttpBinding_CustomerService"
messageEncoding="Mtom" >
<security mode="None" />
</binding>
the question is: why is the front whitespace removed at service side when using this binding?
however,
1. if we use "Text" instead of "Mtom", no whitespace removed at service side. 2. if we remove <security mode="None" />
and keep "Mtom", also no whitespace removed at service side.
client side ---
string customerName = " before and after ";
double totalAmount = customerAccountService.AddBalance(customerName , 100);
service side ---
the customerName becomes "before and after "Microsoft has confirmed this as a bug:
http://connect.microsoft.com/wcf/feedback/details/619894/strings-stripped-of-leading-whitespace-when-using-mtom-message-encoding
精彩评论