Reuse of Model in Front End

B

Brian Smith

Good afternoon. I have a question about being able to reuse a model object
in both the web services side and client side. Suppose I create a data
object called test.DataObject1.

I have a web service method: "InsertData(DataObject1 dobj1)"
When I create the web reference from the ASP.NET client application, it
cerates a proxy object for DataObject1. Is there an easy way to force the
web reference not to use a proxy object but to reinstantiate the
test.DataObject1?

Thanks.
 
J

Jan Tielens

No, there is no easy way... You would have to write your own mapping from
the SOAP message to your custom object (or from the generated proxy to your
own object).
 
B

Brian Smith

Are you saying that I have to edit the generated Reference.cs to cast the
returned data to my data type? I attempted this and it worked. Obviously I
don't want to use this approach because of the manual chaning of generated
code. (Hard to maintain).

It would seem that MS should provide an easy hook for this. This way, I
could easily replace the web services with remoting or direct calls based on
the deployment scenario.

Thanks for the help. If anyone has other thoughts then please let me know.
 
J

Jan Tielens

Are you saying that I have to edit the generated Reference.cs to cast the
returned data to my data type?

That would be a solution. But as you discoverd this has some drawbacks. You
could also write a wrapper class outside the reference.cs file. This will
prevent that if you update your web reference, your code will be replaced.
Following article gives a very generic examples:
http://tinyurl.com/2ttfd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top