Posted By: Remon | Jan 12th, 2007 @ 4:03 PM
page 1 of 1
Comments: 6 | Views: 3847

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

Dr Herbie
Dr Herbie
Half the population have below average IQ
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.
JohnAskew
JohnAskew
9 girl in pink sweater

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.

 

blowdart
blowdart
Peek-a-boo
Remon wrote:


The problem is WS is message driven not class-driven.


That's by design though. WS isn't remoting Smiley
JohnAskew
JohnAskew
9 girl in pink sweater
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.
page 1 of 1
Comments: 6 | Views: 3847