如何从返回自定义对象的 Web 服务中捕获异常?
我看过这篇文章,但它似乎没有显示如何获取服务引发的异常。
我可以提取 SOAP 异常,但我希望能够获取 Web 服务返回的原始异常。我查看了此时设置的变量,似乎在任何地方都看不到异常,我只是看到:
"Server was unable to process request. ---> Exception of type
'RestoreCommon.ConsignmentNotFoundException' was thrown."
try
{
Consignment cons = WebServiceRequest.Instance.Service
.getConsignmentDetails(txtConsignmentNumber.Text);
lblReceiverName.Text = cons.Receiver.Name;
}
catch (ConsignmentNotFoundException)
{
MessageBox.Show("Consignment could not be found!");
}
这可能吗?