私は、VB.NETの "WCF Rest Service Application"プロジェクトテンプレートを使用して非常に簡単なWebサービスを構築しました(これは良い選択ですか?)。私の答えには、避ける方法<string xmlns = "http://schemas.microsoft.com/2003/10/Serialization/">?
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
...
</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,"userID":"0","message":"Empty body"}
</string>
は、任意のはあります方法私は私の文字列の答えのこの不要なシリアル化を避けることができますか?
おそらく、上記はすべて前もって回答済みです。ここを見てくださいhttp://stackoverflow.com/a/8344219/1093668 – athoik