什么是默认的 WCF 绑定? [英] What is the default WCF Binding?
问题描述
我已经为这个问题苦苦挣扎了几天,在这个过程中学习了很多关于绑定的东西.不过,有一件事让我感到困惑:各种链接(参见 this 或 that 例如)明确声明默认情况下,WCF 项目是使用 WsHttpBinding 创建的",但这不是我所看到的.这就是我所做的:
I've been struggling for a few days with this problem, learning a lot of things on bindings in the process. One thing puzzles me, though: various links (see this or that for example) explicitly state "By default, WCF project is created using WsHttpBinding", but that's not what I see. This is what I do:
- 打开 Visual Studio 2010 并选择新建项目/Visual C#/WCF 服务应用程序
- 不要触及代码中的任何内容,为服务设置本地 IIS Url(比如 http://localhost/WcfService7)
- 打开soapUI并选择File/New Soap UI Project/输入新创建的wsdl的url:http://localhost/WcfService7/Service1.svc?wsdl,不涉及任何其他选项
- 接口属性:SOAP 版本 = SOAP 1.1,Binding = "BasicHttpBinding_IService1"(尽管它只是一个名称,但它是一个提示)
- 打开 Altova XmlSpy 并选择 SOAP/创建新的 SOAP 请求/输入 wsdl 的 url/选择任何操作
- SOAP/更改 SOAP 请求参数/确保选中作为 SOAP+XML (SOAP 1.2) 发送"
SOAP/向服务器发送请求:我收到错误
- Open Visual Studio 2010 and choose New Project / Visual C# / WCF Service Application
- Don't touch anything inside the code, set a local IIS Url for the service (say http://localhost/WcfService7)
- Open soapUI and choose File / New Soap UI Project / enter the url of the newly created wsdl: http://localhost/WcfService7/Service1.svc?wsdl, not touching any other option
- Interface properties: SOAP Version = SOAP 1.1, Binding = "BasicHttpBinding_IService1" (even though it's just a name, it's a hell of a hint)
- Open Altova XmlSpy and choose SOAP / Create new SOAP Request / enter the url of the wsdl / select any operation
- SOAP / Change SOAP Request parameters / Ensure that "Send as SOAP+XML (SOAP 1.2)" is checked
SOAP / Send request to server: i get the errors
HTTP 错误:无法在服务器 'localhost' (415) 上 POST 文件'/WcfService7/Service1.svc'
HTTP error: could not POST file ‘/WcfService7/Service1.svc’ on server ’localhost’ (415)
将soap 数据发送到'http://localhost/WcfService7/Service1.svc' 时出错HTTP 错误:无法在服务器10.51.0.108"(415)上发布文件/WcfService7/Service1.svc"
Error sending the soap data to ‘http://localhost/WcfService7/Service1.svc’ HTTP error: could not POST file ‘/WcfService7/Service1.svc’ on server ’10.51.0.108’ (415)
有什么解释吗?谢谢
推荐答案
在 IIS 中托管 WCF 服务(使用 WCF 服务应用程序项目模板)时,使用默认 .svc 文件(不更改其服务主机工厂)时,默认绑定为 基本HttpBinding
.如果要将默认绑定更改为 wsHttpBinding
,则必须使用:
When hosting WCF service in IIS (using WCF Service application project template) with default .svc file (without changing its service host factory) the default binding is basicHttpBinding
. If you want to change default binding to wsHttpBinding
you must use:
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
在您的服务的配置文件中,但它不会解决您的问题,因为您不需要 wsHttpBinding
并且我记得 Altova XmlSpy 无法发送对 wsHttpBinding
因为它只支持基本的 SOAP 堆栈,没有 WS-* 协议.
In your service's configuration file but it will not solve your problem because you don't need wsHttpBinding
and as I remember Altova XmlSpy is not able to send valid request for wsHttpBinding
because it supports only basic SOAP stack without WS-* protocols.
这篇关于什么是默认的 WCF 绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!