.net 下载 WCF 服务公开的所有 WSDL 文件的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/286657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best way to download all of the WSDL files exposed by a WCF service?
提问by Thomas Bratt
What is the best way to download all of the WSDL files exposed by a WCF service?
下载 WCF 服务公开的所有 WSDL 文件的最佳方法是什么?
For example, the root WSDL file references the following other WSDL files:
例如,根 WSDL 文件引用以下其他 WSDL 文件:
<xsd:import schemaLocation="http://localhost:80/?xsd=xsd0" namespace="http://tempuri.com"/>
<xsd:import schemaLocation="http://localhost:80/?xsd=xsd1" namespace="http://tempuri.com"/>
Ideally it would be possible to automate the download so that every time the WSDL changes it would be easy to distribute the files to a customer or incorporate into a document/SDK.
理想情况下,可以自动下载,这样每次 WSDL 更改时,都可以轻松地将文件分发给客户或合并到文档/SDK 中。
采纳答案by Thomas Bratt
回答by Bernard Vander Beken
Meanwhile, disco.exe is considered obsolete technology by Microsoft.
同时,disco.exe 被微软视为过时技术。
You can use svcutil.exe /t:metadatato achieve the same in the WCF age. Additional benefits are support for additional features, eg WS-Policy.
您可以使用 svcutil.exe /t:metadata在 WCF 时代实现相同的功能。其他好处是支持其他功能,例如 WS-Policy。
Save schema from URL:
从 URL 保存架构:
svcutil /t:metadata http://host/pathtomy.svc?wsdl
svcutil /t:metadata http://host/pathtomy.svc?wsdl
Save schema from assembly, eg in automated build:
从程序集保存模式,例如在自动构建中:
svcutil /t:metadata c:\wcfweb\pathToWcfServiceAssembly.dll
svcutil /t:metadata c:\wcfweb\pathToWcfServiceAssembly.dll
回答by tomasr
If you own the service, another interesting option you could explore is using Christian Weyer's FlatWSDL behavior, which will force WCF to generate everything in a single WSDL document, which should make it a lot easier for you to distribute it.
如果您拥有该服务,那么您可以探索的另一个有趣选项是使用 Christian Weyer 的FlatWSDL 行为,这将强制 WCF 在单个 WSDL 文档中生成所有内容,这将使您更容易分发它。
回答by Balazs Zsoldos
There is a simple code snippet that makes it possible downloading a WSDL and all the belonging XSD files for offline use (for example for code generation).
有一个简单的代码片段可以下载 WSDL 和所有属于的 XSD 文件以供离线使用(例如用于代码生成)。
Update
更新
The blog where the code snippet was shown is not available anymore. Luckily, Pablo Diez created a small project based on my blog post and uploaded it to github. It is available now here: https://github.com/pablod/xsd-downloader
显示代码片段的博客不再可用。幸运的是,Pablo Diez 根据我的博文创建了一个小项目并将其上传到 github。现在可以在这里找到:https: //github.com/pablod/xsd-downloader

