什么是默认的WCF绑定?

Pid*_*ddu 13 wcf wcf-binding

我一直在努力解决这个问题,在这个过程中学习很多关于绑定的东西.但有一件事让我感到困惑:各种链接(例如,参见这个那个)明确说明"默认情况下,使用WsHttpBinding创建WCF项目",但这不是我所看到的.这就是我做的:

  1. 打开Visual Studio 2010并选择"新建项目/ Visual C#/ WCF服务应用程序"
  2. 不要触摸代码中的任何内容,为服务设置本地IIS Url(比如http:// localhost/WcfService7)
  3. 打开soapUI并选择File/New Soap UI Project /输入新创建的wsdl的URL:http://localhost/WcfService7/Service1.svc?wsdl,不触及任何其他选项
  4. 接口属性:SOAP版本= SOAP 1.1,绑定="BasicHttpBinding_IService1"(即使它只是一个名字,这是一个暗示的地狱)
  5. 打开Altova XmlSpy并选择SOAP/Create new SOAP Request /输入wsdl/select任意操作的url
  6. SOAP/Change SOAP Request参数/确保选中"Send as 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)

有什么解释吗?谢谢

Lad*_*nka 11

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

<protocolMapping>
    <add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
Run Code Online (Sandbox Code Playgroud)

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