【问题标题】:How to get the wsdl file from a webservice's URL如何从 Web 服务的 URL 获取 wsdl 文件
【发布时间】:2019-03-09 17:10:55
【问题描述】:

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

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

【问题讨论】:

    标签: wsdl


    【解决方案1】:

    通过在 URL 后面加上 ?WSDL

    如果网址是例如:

    http://webservice.example:1234/foo
    

    你使用:

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

    然后 wsdl 将被交付。

    【讨论】:

    • 有时也全部大写(WSDL)
    • 如果你没有得到 wsdl,你可能会得到一个带有绑定键或某种验证代码的 xml,这将帮助你编写 wsdl 的实际 url。
    • 知道如何获取导入的 xsd 文件吗?
    • 这不起作用。这是我的网络服务网址:prealert-test.customer-pages.com
    • ?WSDL 是一种约定,通常由框架等遵循。如果它不适合你,我想你应该为你正在使用的框架找到一些特定的东西。
    【解决方案2】:

    从 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

    【讨论】:

    • 你将如何使用 url 检索一些数据?
    • 如果你想从 SOAP 中检索数据,你应该使用这个工具 soapui.org 它是免费的并且工作正常。
    【解决方案3】:

    只有当 web 服务被配置为交付它时,它才有可能获取 WSDL。因此,您必须指定 serviceBehavior 并启用 httpGetEnabled:

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

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

    【讨论】:

      【解决方案4】:

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-22
        • 2010-10-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多