Search code examples
c#web-servicesproxy-classes

Using a webservice type directly through the DLL


I have a webservice with a function that returns a type (foo). If I consume this webservice in .NET through the 2.0 generated proxies, it creates a class called foo in the generated proxy. If I have the DLL that contains that class (foo) that is the DLL being used by the webservice, is there any way to have it use that class instead of creating a custom proxy class? I'm looking for something similar to what remoting does... but not remoting.


Solution

  • I've seen 3 ways of doing this:

    1. Let Visual Studio generate the proxy and then change the classes in the proxy to the full class names of the dll, by hand. Works, but you would have to do this again everytime you update your proxy. Plus it's really dirty, isn't it?
    2. Use a generic class/method that creates deep copies of your proxy objects into the "real" objects by reflection. Works, but of course with a little performance offtrade
    3. Use WCF, where you can reference the dll with the data contracts (your data classes) and use them instead of creating any proxy by code generation.