【发布时间】:2019-03-09 17:10:55
【问题描述】:
我想获取 Web 服务的 WSDL 文件,而我唯一拥有的是它的 URL(如 webservice.example/foo)。
如果我直接使用 URL,则只会传递错误响应。
【问题讨论】:
标签: wsdl
我想获取 Web 服务的 WSDL 文件,而我唯一拥有的是它的 URL(如 webservice.example/foo)。
如果我直接使用 URL,则只会传递错误响应。
【问题讨论】:
标签: wsdl
通过在 URL 后面加上 ?WSDL
如果网址是例如:
http://webservice.example:1234/foo
你使用:
http://webservice.example:1234/foo?WSDL
然后 wsdl 将被交付。
【讨论】:
WSDL (Web Service Description Language)。可以通过 SOAP Web 服务实现:
http://www.w3schools.com/xml/tempconvert.asmx
要获取 WSDL,我们只需添加 ?WSDL ,例如:
【讨论】:
只有当 web 服务被配置为交付它时,它才有可能获取 WSDL。因此,您必须指定 serviceBehavior 并启用 httpGetEnabled:
<serviceBehaviors>
<behavior name="BindingBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
如果 web 服务只能通过 https 访问,您必须启用 httpsGetEnabled 而不是 httpGetEnabled。
【讨论】:
要使用 Visual Studio 的开发人员命令提示符从 url 下载 wsdl,请在管理员模式下运行它并输入以下命令:
svcutil /t:metadata http://[your-service-url-here]
您现在可以根据需要在项目中使用下载的 wsdl。
【讨论】: