Hi,
I have an abstract class "BaseRecord" that implements an interface "IRecord".
I have WebMethod Update which take BaseRecord as a parameter.
The problem is it considers the following:
VS consider the 2 classes (the original & the proxy class generated by wsdl) 2 different classes.
I won't pass a BaseRecord class, i will pass objects of classes that inherit the BaseRecord.
What is the best practice of doing such a thing ?
Can this be done using WCF & WebServices ?
Thanks
-
-
Remon wrote:
Hi,
I have an abstract class "BaseRecord" that implements an interface "IRecord".
I have WebMethod Update which take BaseRecord as a parameter.
...
(my emphasis)
So why not pass the parameter as an IRecord? It will de-couple the objects even more that passing a base class.
Herbie.
-
They are 2 different classes. Create a proxy class for, and populate it from, the original BaseRecord-derived object for use with web services. The web service will need the XML-serializable proxy class (lightweight, text only) and not BaseRecord derived objects (heavy, binary). Web Methods will use the proxy classes.
-
IRecord cannot be a parameter to a WebMethod as it cannot be serialized.
-
JohnAskew wrote:
They are 2 different classes. Create a proxy class for, and populate it from, the original BaseRecord-derived object for use with web services. The web service will need the XML-serializable proxy class (lightweight, text only) and not BaseRecord derived objects (heavy, binary). Web Methods will use the proxy classes.
This cannot be done too unluckly, the problem is this code is so dynamic, (even the BaseRecord-driven classes are loaded in run time)
so we need to pass the BaseRecord or the IRecord.
The problem is WS is message driven not class-driven.. so i have no idea how to send a class ( say CarRecord::BaseRecord) as BaseRecord, then unboxing it as CarRecord at the WS end.
-
Remon wrote:
The problem is WS is message driven not class-driven.
That's by design though. WS isn't remoting
-
Remon wrote:

JohnAskew wrote: They are 2 different classes. Create a proxy class for, and populate it from, the original BaseRecord-derived object for use with web services. The web service will need the XML-serializable proxy class (lightweight, text only) and not BaseRecord derived objects (heavy, binary). Web Methods will use the proxy classes.
This cannot be done too unluckly, the problem is this code is so dynamic, (even the BaseRecord-driven classes are loaded in run time)
so we need to pass the BaseRecord or the IRecord.
The problem is WS is message driven not class-driven.. so i have no idea how to send a class ( say CarRecord::BaseRecord) as BaseRecord, then unboxing it as CarRecord at the WS end.
What about an abstract method in BaseRecord that generates proxy class - messages for the XML transfer?
I'm not sure how dynamic code precludes this...
WCF more formally supports a 'Contract' between web service and consumers. XML messages are designed explicitly, and seperate from the objects themselves. Even proxy objects generated via wsdl should be understood to be XML messages. Messages could include the Type name and data, etc... These messages can have an object-oriented design such that the service accepts a base and each message can be a derivative of it.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.