M
Michael Carr
I am writing a client that consumes a web service and extends the
functionality of one of the web service's classes. The definition is
something like this:
/* This class is defined within the webservice and
added to the client as a Web Reference */
class ServerClass
{ ... }
/* This class exists inside the client only and inherits from the
class above to add additional functionality */
class ClientClass : ServerClass
{ ... }
Now, I'd like to call a WebMethod and pass a ClientClass where it would
normally expect a ServerClass parameter, since I've been working with an
instance of ClientClass locally. On the server, this WebMethod is defined
as:
[WebMethod]
void ServerMethod(ServerClass a)
{ ... }
I would like to call it from the client as
ClientClass b; // Derives from ServerClass
ServerMethod(b);
which seems like it should be possible since ClientClass inherits from
ServerClass... However, when I try to execute this WebMethod I get the
message "An unhandled exception of type 'System.InvalidOperationException'
occurred in system.xml.dll. Additional information: There was an error
generating the XML document."
Are there any tricks I need to play in order to pass a derived class into a
WebMethod?
Thank you for any help,
Michael Carr
functionality of one of the web service's classes. The definition is
something like this:
/* This class is defined within the webservice and
added to the client as a Web Reference */
class ServerClass
{ ... }
/* This class exists inside the client only and inherits from the
class above to add additional functionality */
class ClientClass : ServerClass
{ ... }
Now, I'd like to call a WebMethod and pass a ClientClass where it would
normally expect a ServerClass parameter, since I've been working with an
instance of ClientClass locally. On the server, this WebMethod is defined
as:
[WebMethod]
void ServerMethod(ServerClass a)
{ ... }
I would like to call it from the client as
ClientClass b; // Derives from ServerClass
ServerMethod(b);
which seems like it should be possible since ClientClass inherits from
ServerClass... However, when I try to execute this WebMethod I get the
message "An unhandled exception of type 'System.InvalidOperationException'
occurred in system.xml.dll. Additional information: There was an error
generating the XML document."
Are there any tricks I need to play in order to pass a derived class into a
WebMethod?
Thank you for any help,
Michael Carr