I am writing some ASMX.NET 2.0 services. I have a scenario where I need to create a web service proxy with WSDL.exe, but the generated class does not implement the interface, so I can not fake the web service for testing.
Here's one approach I'm trying to do, but it does not compile at the moment: I know that WSDL.exe can generate interfaces using the parameter /serverInterface. Basically, I would like to generate both interfaces and proxy classes as follows:
wsdl MyWebService.wsdl / nologo / l: CS /namespace:Juliet.Services /o:C:\projects\JulietService\MyWebServiceInterface.cs / ServerInterface
wsdl MyWebService.wsdl / nologo / l: CS /namespace:Juliet.Services /o:C:\projects\JulietService\MyWebServiceProxy.cs
Then include both files in my project. After that, I would have to get my own class from the generated proxy and implement the generated interface as follows:
public class MockableWebService : MyWebService, IMyWebServiceSoap11Binding
{
}
This should work in principle, except that both interface files and proxy files will automatically generate the same class definitions for my Request / Response messages, resulting in hundreds of type errors The namespace 'Juliet.Services' already contains a definition for 'ABC'.
I would like the interface / proxy generation to be as automated as possible - this means that I want to avoid manually changing the generated code at all costs.
Can anyone suggest a way to create an interface and proxy at the same time as WSDL.exe or a better way to get the results described above?