I'm writing some .NET 2.0 ASMX services. I have a scenario where I need to generate a web service proxy with WSDL.exe, but the generated class doesn't implement an interface, so I can't fake out the web service for testing.
Here's one approach I'm trying, but it doesn't compile at the moment: I'm aware that WSDL.exe can generate interfaces using the /serverInterface
option. In principle, I'd like to generate both Interface 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. Afterward I should be able to derive my own class from the generated Proxy and implement the generated interface as follows:
public class MockableWebService : MyWebService, IMyWebServiceSoap11Binding
{
// No implementation, the interface is already implicitly implemented
// from the methods in the base class.
}
This should work in principle, except both interface and proxy files will auto-generate the same class definitions for my Request/Response messages, resulting in hundreds of errors of the type The namespace 'Juliet.Services' already contains a definition for 'ABC'
.
I'd like to keep the interface/proxy generation as automated as possible -- meaning, I want to avoid modifying generated code by hand at all costs.
Can anyone suggest a way to generate the interface and proxy at the same time with WSDL.exe, or a better way to get the results described above?
wsdl.exe helps create ASP.NET Web Services and proxies for their clients. The most common usage of wsdl.exe is to generate proxy classes for web services: wsdl /command:proxy /path:path /language:language /namespace:namespace /out:output /protocol:protocol.
After creating the directory we will write a Proxy class by “wsdl” command on a specified location. Just write wsdl and paste your URL that was copied from the web browser of the web service file . asmx and press Enter to create it. It will create a Proxy class on the selected location.
Doesn't the .NET 2.0 WSDL.EXE generate partial classes? Then you can implement the interface on another class part:
public partial class MockableWebService : IMyWebServiceSoap11Binding
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With