SvcUtil vs WseWsdl3

时间:2016-03-25 15:38:03

标签: c# wsdl stub svcutil.exe wse

官方VmWare documentation介绍了如何使用WseWsdl3.exe实用程序从一组VimService.cs文件生成csharp文件.wsdl

  

wsewsdl3.exe / n:Vim25Api / type:webClient / l:CS vim.wsdl vimService.wsdl

由于不推荐使用包Microsoft Web Services Enhancements (WSE) 3.0 for Microsoft .NET,因此可以选择生成相同的VimService.cs(假设使用实用程序SvcUtil.exe)?

最终目标是创建一个自包含脚本文件,该文件可以生成最终Vim25Service.dll而无需安装任何旧的和不必要的包。 WseWsdl3.exe的不好之处在于它不尊重the principle of least privilege,即它在系统注册表中查找支持wsdl.exe实用程序的路径,这使得{{1}不可移植的。幸运的是WseWsdl3.exe是一个.NET应用程序,我可以自己轻松修改它,因此它需要WseWsdl3.exe作为参数的路径,但不幸的是,许可证不允许逆向工程,特别是重新编译该计划。

当我尝试使用wsdl.exe时:

  

SvcUtil.exe / language:cs vim.wsdl vimService.wsdl

SvcUtil.exe
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: There was a problem loading the XSD documents provided: a reference to a schema type with name 'DestroyPropertyFilterRequestType' and namespace 'urn:vim25' could not be resolved because the type definition could not be found in the schema for targetNamespace 'urn:vim25'. Please check the XSD documents provided and try again.

1 个答案:

答案 0 :(得分:1)

使用wsdl生成C#文件。

wsdl /n:Vim25Api /o:VimService.cs vim.wsdl vimService.wsdl 

https://msdn.microsoft.com/en-us/library/7h3ystb6(v=vs.100).aspx