What is the default WCF Binding?

人盡茶涼 提交于 2020-01-01 08:03:12

问题


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:

  1. Open Visual Studio 2010 and choose New Project / Visual C# / WCF Service Application
  2. Don't touch anything inside the code, set a local IIS Url for the service (say http://localhost/WcfService7)
  3. 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
  4. Interface properties: SOAP Version = SOAP 1.1, Binding = "BasicHttpBinding_IService1" (even though it's just a name, it's a hell of a hint)
  5. Open Altova XmlSpy and choose SOAP / Create new SOAP Request / enter the url of the wsdl / select any operation
  6. SOAP / Change SOAP Request parameters / Ensure that "Send as SOAP+XML (SOAP 1.2)" is checked
  7. SOAP / Send request to server: i get the errors

    HTTP error: could not POST file ‘/WcfService7/Service1.svc’ on server ’localhost’ (415)

    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)

Any explanations? Thanks


回答1:


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>

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.




回答2:


The default is basichttpbinding using SOAP 1.1.

That is why you get an error sending it as SOAP 1.2.



来源:https://stackoverflow.com/questions/6263813/what-is-the-default-wcf-binding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!