I’ve built a set of WCF web services on .NET 4.0 and now need to consume them in an ASP.NET 2.0 website. I’ve been able to get the web reference in VS 2005, however I’m having a problem:
The service reference is incomplete.
The service defines two types of faults. These faults are being read by VS2010 and .NET 4 correctly, but not by VS 2005 and .NET 2, resulting in an incomplete web reference.
What could be causing this? Is there any way to solve this, or should I resort to not using a reference and just post the XML myself?
Web References (and the ASMX technology in general) do not support faults. This is not just a problem in referencing WCF services, but rather services in general.
The best you can do is catch the
SoapExceptionexception and look at theDetailproperty to see what kind of fault was sent. But you cannot catch individual exceptions per fault.Similarly, if you were writing an ASMX service, you would find that the auto-generated WSDL cannot describe faults that your service returns; in fact, there is no way to indicate that your service returns faults.
There is a fix for this problem – WCF. Unfortunately, if you’re stuck at .NET 2.0, then you’re out of luck.
You should be aware, however, that .NET 3.5 is nothing more than .NET 2.0 SP2 plus some new assemblies. It’s safe to upgrade.