Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET WebReference to Webservice - generating interface together with proxy class

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

like image 819
cubesoft Avatar asked Jun 22 '10 13:06

cubesoft


2 Answers

@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
    {
    } 
}
like image 88
John Saunders Avatar answered Sep 30 '22 10:09

John Saunders


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

like image 21
Koynov Avatar answered Sep 30 '22 09:09

Koynov