开发者

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 s开发者_如何学JAVAuggest 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?


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
{
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜