Jul*_*iet 5 c# wsdl web-services
我正在编写一些.NET 2.0 ASMX服务.我有一个场景,我需要使用WSDL.exe生成一个Web服务代理,但生成的类没有实现一个接口,所以我不能伪造Web服务进行测试.
这是我正在尝试的一种方法,但目前还没有编译:我知道WSDL.exe可以使用该/serverInterface
选项生成接口.原则上,我想产生两种接口和代理类,如下所示:
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
然后在我的项目中包含这两个文件.之后我应该能够从生成的Proxy派生自己的类,并按如下方式实现生成的接口:
public class MockableWebService : MyWebService, IMyWebServiceSoap11Binding
{
// No implementation, the interface is already implicitly implemented
// from the methods in the base class.
}
Run Code Online (Sandbox Code Playgroud)
这应该原则上起作用,除了接口和代理文件将自动生成我的请求/响应消息的相同类定义,导致数百种类型的错误The namespace 'Juliet.Services' already contains a definition for 'ABC'
.
我想保持接口/代理生成尽可能自动化 - 这意味着,我想避免不惜一切代价手动修改生成的代码.
任何人都可以建议使用WSDL.exe同时生成接口和代理的方法,或者更好的方法来获得上述结果?
.NET 2.0 WSDL.EXE 不生成部分类吗?然后你可以在另一个类部分实现该接口:
public partial class MockableWebService : IMyWebServiceSoap11Binding
{
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3504 次 |
最近记录: |