提供了故障状态我有一个WCF服务,我打电话方式如下:为WCF服务
MyService client = new MyService();
bool result = client.MyServiceMethod(param1, param2);
可变结果设置为true或false指示成功或失败。在成功的情况下,这是明确的,但在失败的情况下,我需要得到一些失败的细节。
从我的服务,我用
OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;
response.StatusCode = HttpStatusCode.BadRequest;
response.StatusDescription = "Invalid parameter.";
return false;
我的问题是我如何检索响应描述是正确的方式来提供故障反馈?
我该如何从调用程序中检索细节? 对象结果= client.MyServiveMethod(param1,param2);将不起作用 – ElenaDBA
为发布添加了详细信息。如果您有任何问题,请告诉我。 –