Catching a SoapException thrown by a WebService

眉间皱痕 提交于 2019-12-04 06:53:29

I think that the main "problem" is that you are using a WCF Service Reference connecting to an ASP.NET Web Service (.asmx).

The "easiest" way to handle this would probably be to use a Web Reference instead of a WCF Service Reference on the client. You do this by selecting the "Advanced" button on the bottom of the Add Service Reference dialog, and then the Add Web Reference on the bottom of that screen. I believe that using a Web Reference should give you a SoapException.

The correct way (if you want to follow Microsofts advice) would be to publish a WCF service instead of an .asmx service. That is a whole other chapter though..

When an ASMX service throws a SoapException, .NET returns a SOAP Fault message.

A SOAP Fault is returned to a service reference as an exception of type FaultException. So you will never see a SoapException.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!