I have a vendor web service that I have created a web application to
interact with. The service works fine in VS 2003 but fails in VS 2005. I
have implemented a proxy between the web client and web service to capture
the soap calls and both the request and response are identical. The problem
occurs in VS 2005 when the .net runtime attempts to de-serialize the soap
response into the custom type defined in the wsdl. The exact error message
is
Unable to cast object of type 'System.Xml.XmlText' to type
'System.Xml.XmlElement'.
Stack Trace:
[InvalidCastException: Unable to cast object of type 'System.Xml.XmlText' to
type 'System.Xml.XmlElement'.]
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReaderPRISMAPI.Read2_ContactDTO(Boolea n
isNullable, Boolean checkType) +5470
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReaderPRISMAPI.Read30_ContactNewRespon se()
+439
Microsoft.Xml.Serialization.GeneratedAssembly.Arra yOfObjectSerializer25.Deserialize(XmlSerialization Reader
reader) +63
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle, XmlDeserializationEvents events) +336
[InvalidOperationException: There is an error in XML document (1, 685).]
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle, XmlDeserializationEvents events) +781
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle) +53
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
+2551
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters) +292
PrismAPI.PRISMAPI.ContactNew() in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\webui\bcb854b3\dc118bff\App_WebReferences.ca csndbj.0.cs:443
_Default.Page_Load(Object sender, EventArgs e) in
d:\work\<snip>\WebPortalVS\trunk\src\WebUI\Default .aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o,
Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender,
EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3035
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42
My first thought was to look at the type definitions generated when I set
the web reference in VS 2005, but it appears from the stack trace that this
is not available in the IDE at design time as it is dynamically compiled.
How can I see the Xml serialization attributes that were applied when the
web reference was set?
Any help is most appreciated.