我有如下代码:
<OperationContract()>
<Description("")>
<WebGet(Bodystyle:=WebMessageBodyStyle.Bare, UriTemplate:="TestConnection")>
Function TestConnection() As String
Public Function TestConnection() As String Implements ITestSvc.TestConnection
WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"
Return "Connection Success"
End Function
但它返回的是<string xmlns='...'>Connection Success</string>
如果没有 XML 包装器,我如何才能只返回“连接成功”。我知道我们可以用 MessageEncoder 做一些事情。但是,我希望它在操作级别可用(某些操作需要 XML/JSON 包装器,而某些操作不需要)。
谁可以帮我这个事?