ASMX Object -> Proxy Object Conversion

元气小坏坏 提交于 2019-12-24 11:28:20

问题


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:


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.



来源:https://stackoverflow.com/questions/1408687/asmx-object-proxy-object-conversion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!