Linux svcutil.exe - 如何获取 WSDL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5569142/
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
svcutil.exe - How to get WSDL
提问by three-cups
I'm working with a SOAP interface. The interface provider is having trouble getting me the full WSDL (long story). They have asked me to use svcutil.exe to generate everything I need. From what I can tell, svcutil.exe
我正在使用 SOAP 接口。接口提供者无法让我获得完整的 WSDL(长话短说)。他们让我使用 svcutil.exe 来生成我需要的一切。据我所知,svcutil.exe
- requires windows - I don't have a windows box available
- generates C# or VisualBasic
- 需要窗户 - 我没有可用的窗户框
- 生成 C# 或 VisualBasic
It'd be great if it could just spit out a WSDL. Or if there's something I can do from Linux, that would be great too.
如果它可以吐出 WSDL,那就太好了。或者,如果我可以从 Linux 中做一些事情,那也很棒。
Do I have any options from here, or do I just have to wait for the provider to get me the WSDL.
我是否有任何选择,或者我是否只需要等待提供者为我提供 WSDL。
I guess the question is, given a URL and instructions to use svcutil.exe, how can I write code to use a SOAP service only using Linux?
我想问题是,给定一个 URL 和使用 svcutil.exe 的说明,我如何编写代码以仅使用 Linux 使用 SOAP 服务?
采纳答案by grantk
If using linux you could save it via curl
如果使用 linux,您可以通过 curl 保存它
curl url > service.wsdl
so to get a weatherForcast WSDL
所以得到一个weatherForcast WSDL
curl http://www.webservicex.net/WeatherForecast.asmx?WSDL > weatherForcast.wsdl
回答by razlebe
@grantkhas already demonstrated the easiest method: if you know where the WSDL is hosted, you can simply fetch the document using your tool of choice.
@grantk已经演示了最简单的方法:如果您知道 WSDL 的托管位置,则可以使用您选择的工具简单地获取文档。
But as you asked specifically about using SVCUtil: you could find a windows box, use SVCUtil to fetch the WSDL, and then return to your linux (and Java?) stack and generate client proxies from that WSDL to call the service using your web service framework of choice.
但是,正如您专门询问使用 SVCUtil:您可以找到一个 Windows 框,使用 SVCUtil 获取 WSDL,然后返回到您的 linux(和 Java?)堆栈并从该 WSDL 生成客户端代理以使用您的 Web 服务调用该服务选择的框架。
If the target service supports WS-MetadataExchangeor XML Web Service Discovery, SVCUtil will locate and download the WSDL for you: see this HowToon Microsoft's MSDN web site.
如果目标服务支持WS-MetadataExchange或XML Web Service Discovery,SVCUtil 将为您定位并下载 WSDL:请参阅Microsoft 的 MSDN 网站上的此 HowTo。
Using the weather forecast service example that @grantkused, you can ask SVCUtil to query the service and download metadata as follows:
使用@grantk使用的天气预报服务示例,您可以要求 SVCUtil 查询服务并下载元数据,如下所示:
svcutil /t:metadata http://www.webservicex.net/WeatherForecast.asmx
(I'm sure there are similar tools to do this using WS-MetadataExchange in the linux world, but my experience is with SVCUtil.)
(我确定在 linux 世界中使用 WS-MetadataExchange 有类似的工具可以做到这一点,但我的经验是使用 SVCUtil。)