views:

43

answers:

2

Hello

I have a WebService project in VS2005 and a Mobile Device .NET CF project. I add web reference to the WebService and thus I have a Reference.cs generated with proxy class. My problem is that I'd also like to have the pure interface generated and the proxy class to implement this interface. I want to use this interface to provide a custom implementation as a fall back when WebService is not available. Is it possible with VS2005 and WSDL generator?

Thanks

+3  A: 

I don't know a way to generate an interface implemented by the proxy for the service.

You can try to use Refactor->Extract Interface for the generated proxy class. Afterward you can write a wrapper class which inherits the proxy and implement extracted interface. Instead of writing a wrapper class you could just tweak the generated proxy class and say it will implement extracted interface.The drawback of choosing the second approach is that you mess with auto generated code which is not a good idea in general

Koynov
+4  A: 

@Koynov has the basic idea. But instead of inheriting from the proxy class, create another partial class part. Assuming the service is named MyService, the web reference is named "Proxy" and your default namespace is "Namespace", create a new folder named "Proxy". In that folder, create a new class named MyService:

namespace Namespace.Proxy
{
    public partial class MyService : IMyService
    {
    } 
}
John Saunders
This is much more cleaner. +1
Koynov