wsdl.exe generator for WSDL with modeled soap faults
Here is common problem with faults modeled using WSCF (WebServiceContractFirst) tool – while trying to generate C# Proxy for a webservice WSDL, I have kept getting the following error:
Error: Unable to cast object of type ‘System.Xml.XmlElement’ to type ‘System.Web
After a careful investigation of WSDL on W3C, I have discovered that the the bogus definition ( that wsdl.exe can’t understand) was in fault section of the binding:
<binding name=”SOAServices“ type=”tns:SOAServicesInterface“>
<soap:operation soapAction=”soa:validateUserIn“ style=”document“/>
Replacing the definition to include soap:fault instead of soap:body resolves the problem.
<wsdl:fault name=” ValidateUserFault “>
<soap:fault name=” ValidateUserFault “ use=”literal“/>
It would have been nice if wsdl.exe will generate more information for the errors, but ….