gpt4 book ai didi

wcf - 什么是默认的 WCF 绑定(bind)?

转载 作者:行者123 更新时间:2023-12-03 23:46:42 25 4
gpt4 key购买 nike

我已经与 this problem 苦苦挣扎了几天,过程中学习了很多关于绑定(bind)的东西。
不过,有一件事让我感到困惑:各种链接(例如,参见 thisthat)明确声明“默认情况下,WCF 项目是使用 WsHttpBinding 创建的”,但这不是我所看到的。
这就是我所做的:

  • 打开 Visual Studio 2010 并选择 New Project/Visual C#/WCF Service Application
  • 不要触摸代码中的任何内容,为服务设置本地 IIS Url(例如 http://localhost/WcfService7 )
  • 打开soapUI并选择File/New Soap UI Project/输入新创建的wsdl的url:http://localhost/WcfService7/Service1.svc?wsdl ,不触及任何其他选项
  • 接口(interface)属性:SOAP Version = SOAP 1.1, Binding = "BasicHttpBinding_IService1"(虽然只是一个名字,但它是一个提示)
  • 打开 Altova XmlSpy 并选择 SOAP/创建新的 SOAP 请求/输入 wsdl 的 url/选择任何操作
  • SOAP/更改 SOAP 请求参数/确保选中“作为 SOAP+XML (SOAP 1.2) 发送”
  • SOAP/向服务器发送请求:我收到错误

    HTTP 错误:无法在服务器“localhost”上发布文件“/WcfService7/Service1.svc”(415)

    将肥皂数据发送到“http://localhost/WcfService7/Service1.svc”时出错' HTTP 错误:无法在服务器 '10.51.0.108' 上发布文件 '/WcfService7/Service1.svc' (415)

  • 有什么解释吗?谢谢

    最佳答案

    当使用默认 .svc 文件(不更改其服务主机工厂)在 IIS 中托管 WCF 服务(使用 WCF 服务应用程序项目模板)时,默认绑定(bind)为 basicHttpBinding .如果您想将默认绑定(bind)更改为 wsHttpBinding你必须使用:

    <protocolMapping>
    <add scheme="http" binding="wsHttpBinding"/>
    </protocolMapping>

    在您服务的配置文件中,但它不会解决您的问题,因为您不需要 wsHttpBinding我记得 Altova XmlSpy 无法为 wsHttpBinding 发送有效请求因为它只支持没有 WS-* 协议(protocol)的基本 SOAP 堆栈。

    关于wcf - 什么是默认的 WCF 绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263813/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com