Hello,
I have designed a WebService with the following method :
[WebMethod]
public DbAppAnswer GetDs(DbAppRequest request)
DbAppRequest and DbAppAnswer are defined as :
public class DbAppRequest : DbAppMessageBase
public class DbAppAnswer : DbAppMessageBase
public abstract class DbAppMessageBase : XmlDocument
Now up on the call to WebMethod GetDs, I have the following exception :
---------------------------------------------------8<-------------------------------------------------------------------------
System.Web.Services.Protocols.SoapException: Server was unable to read
request. ---System.InvalidOperationException: There is an error in
XML document (1, 370). ---System.InvalidCastException: Unable to cast
object of type 'System.Xml.XmlElement' to type
'DbAppFrameworkMessages.DbAppRequest'.\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_GetDs()\n
at
Microsoft.Xml.Serialization.GeneratedAssembly.Arra yOfObjectSerializer.Deserialize(XmlSerializationRe ader
reader)\n at
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle, XmlDeserializationEvents events)\n --- End of
inner exception stack trace ---\n at
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle, XmlDeserializationEvents events)\n at
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle)\n at
System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()\n
--- End of inner exception stack trace ---\n at
System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()\n
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()
---------------------------------------------------8<-------------------------------------------------------------------------
Another thing I noticed is that the generated proxy has this signature
:
public System.Xml.XmlNode GetDs(System.Xml.XmlNode request)
Well I understand that there's a problem on the server-side : the
request is sent as an XmlElement and
there's an exception casting an XmlElement to DbAppRequest.
What guidance could you give me ?
Should I write a "cast-operator" in DbAppRequest so as to automatically
cast XmlElement to DbAppRequest ?
Also, what best practices could you give me so as to optimize the body
of the SOAP message since DbAppRequest is already XML.
Thanks a lot for your answers,
Olivier.