我使用VB.NET“WCF Rest Service Application”项目模板构建了一个非常简单的Web服务(这是一个不错的选择吗?).我工作得很好,除了有事实
原文链接:https://www.f2er.com/vb/255812.html<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"> ... </string>
添加到我的答案.
我已将我的返回值声明为String:
<WebInvoke(UriTemplate:="member/login",Method:="POST",responseformat:=WebMessageFormat.Json,BodyStyle:=WebMessageBodyStyle.Bare)> Public Function Create(data As IO.Stream) As String Dim strData As String = New IO.StreamReader(data).ReadToEnd() Dim UserAccessForm As LoginAccess = Me.getAnswer(strData) Dim jsonAnswer As String jsonAnswer = Newtonsoft.Json.JsonConvert.SerializeObject(UserAccessForm,Newtonsoft.Json.Formatting.None) Return jsonAnswer End Function
所以不要回答这个问题:
{"logged":false,"userID":"0","message":"Empty body"}
我明白了:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"> {"logged":false,"message":"Empty body"} </string>
有什么方法可以避免我的字符串答案的这种不必要的序列化?