tags:

views:

194

answers:

1

Is there a way to convert an instance of an object to an instance of a web service proxy of the same type?

It seems like this is something .NET has to be capable of under the hood, so I'm just trying to find and re-use this function.

It's definitely a little awkward, but I have access to both types in my project through a common library, and it would be very convenient for my purposes to be able to work with the real object, and then convert it to the proxy type at the last minute before invoking the web service.

Since I'm sure someone will ask - I can potentially switch to a WCF client, but the service is ASMX, and that isn't likely to change any time soon.

I've already tried experimented with trying to generate a WCF client that will re-use the type, and it works fine for WCF services, but doesn't seem to work with ASMX services.

+1  A: 

I have recently used Automapper for this type of operation. It is very useful for mapping Web Service proxies to DTO etc. The project can be found here with some examples of how to use it.

Michael Mann