如何从 Web 服务的 URL 获取 wsdl 文件

问题描述 投票:0回答:5

我想要获取 Web 服务的 WSDL 文件,而我唯一拥有的就是它的 URL(如 webservice.example/foo)。

如果我直接使用 URL,则只会传递错误响应。

wsdl
5个回答
165
投票

通过在 URL 后缀

?WSDL

如果 URL 例如:

http://webservice.example:1234/foo

您使用:

http://webservice.example:1234/foo?WSDL

wsdl 将被交付。


37
投票

从 Web 服务 URL 获取
WSDL
(
Web Service Description Language
)。

可以通过 SOAP Web 服务实现:

http://www.w3schools.com/xml/tempconvert.asmx

要获取 WSDL,我们只需添加

?WSDL
,例如:

http://www.w3schools.com/xml/tempconvert.asmx?WSDL


16
投票

仅当 Web 服务配置为传送 WSDL 时,才可能获取 WSDL。因此,您必须指定一个 serviceBehavior 并启用 httpGetEnabled:

<serviceBehaviors>
    <behavior name="BindingBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
</serviceBehaviors>

如果网络服务只能通过 https 访问,您必须启用 httpsGetEnabled 而不是 httpGetEnabled。


11
投票

要使用 Visual Studio 的开发人员命令提示符从 url 下载 wsdl,请在管理员模式下运行它并输入以下命令:

 svcutil /t:metadata http://[your-service-url-here]

您现在可以根据需要在项目中使用下载的 wsdl。


0
投票
  1. 探索 url + ?wsdl:

    http://localhost:1234/sevice.aspx?WSDL

  2. 右键单击页面并选择另存为...

  3. 选择 XML 格式并单击“保存”。

© www.soinside.com 2019 - 2024. All rights reserved.