什么是默认的WCF绑定?

时间:2011-06-07 10:20:22

标签: wcf wcf-binding

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

  1. 打开Visual Studio 2010并选择“新建项目/ Visual C#/ WCF服务应用程序”
  2. 请勿触摸代码中的任何内容,为服务设置本地IIS网址(例如http://localhost/WcfService7
  3. 打开soapUI并选择File / New Soap UI Project /输入新创建的wsdl的网址:http://localhost/WcfService7/Service1.svc?wsdl,不要触及任何其他选项
  4. 接口属性:SOAP Version = SOAP 1.1,Binding =“BasicHttpBinding_IService1”(尽管它只是一个名字,但它是一个地狱的暗示)
  5. 打开Altova XmlSpy并选择SOAP / Create new SOAP Request /输入wsdl的url / select any operation
  6. SOAP /更改SOAP请求参数/确保选中“以SOAP + XML(SOAP 1.2)发送”
  7. SOAP /向服务器发送请求:我收到错误

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

    将soap数据发送到'http://localhost/WcfService7/Service1.svc时发生错误HTTP错误:无法在服务器'10 .51.0.108上发布文件'/WcfService7/Service1.svc'(415)

  8. 有任何解释吗?感谢

2 个答案:

答案 0 :(得分:11)

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

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

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

答案 1 :(得分:2)

默认是使用SOAP 1.1进行basichttpbinding。

这就是为什么在将其作为SOAP 1.2发送时会出错。

相关问题