Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate both client and interface code from WSDL.exe?

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?

like image 251
Juliet Avatar asked Apr 07 '11 19:04

Juliet


People also ask

What is wsdl EXE?

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.

How do I create a proxy class in wsdl?

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.


1 Answers

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
{
}
like image 111
John Saunders Avatar answered Oct 05 '22 11:10

John Saunders