【发布时间】:2016-06-16 09:00:52
【问题描述】:
我正在开发一个 REST API。 以下是我的代码:
在 IService.vb 中
<OperationContract(),
WebGet(UriTemplate:="/DCU/{ClientID}",
RequestFormat:=WebMessageFormat.Xml,
ResponseFormat:=WebMessageFormat.Xml,
BodyStyle:=WebMessageBodyStyle.Bare)>
Function GetAllData(ByVal ClientID As String) As List(Of Data)
在Service.vb中
Friend Class Service
Implements IService
Public Function GetAllData(ByVal intClientID As String) As System.Collections.Generic.List(Of Data) Implements ILightingGaleService.GetAllDCUs
Dim lstdata As New List(Of Data)()
If IsNumeric(intClientID) Then
Else
Throw New FaultException("Invalid Client ID")
End If
End Class
在 Web.Config 文件中
<serviceDebug includeExceptionDetailInFaults="true"/>
我得到了
请求错误:服务器在处理请求时遇到错误。有关详细信息,请参阅服务器日志。
当我在客户端 ID 中传递字符串值时。虽然我已经实现了 FaultExpcetion,但我从未在 POSTMAN 或 Web 客户端中收到“无效的客户端 ID”消息。
谁能帮助我了解如何在 POSTMAN 或 Web 客户端上获取我的自定义消息?
【问题讨论】: