【问题标题】:My WCF service won't use my wsHttpBinding我的 WCF 服务不会使用我的 wsHttpBinding
【发布时间】:2013-09-19 21:51:36
【问题描述】:

我的 web.config 的 serviceModel 部分:

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="default" closeTimeout="00:01:00" openTimeout="00:01:00"
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="2147483647"  maxReceivedMessageSize="2147483647"
        textEncoding="utf-8"  useDefaultWebProxy="true"
        messageEncoding="Text">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" 
          maxArrayLength="2147483647"
          maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
      </binding>
    </wsHttpBinding>
  </bindings>
  <services>
    <service name="templateMgr">
      <endpoint address="http://edocengine.localtest.me/services/templateMgr.svc"
         name="templateMgr.svc" binding="wsHttpBinding" contract="ItemplateMgr"/>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"
     aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

请注意,我在这里指定了wsHttpBinding,以及一个大的MaxReceivedMessageSize。然而,当我在代码中设置断点时

? System.ServiceModel.OperationContext.Current.Host.Description.Endpoints(0).Binding.Name
"BasicHttpBinding"
? ctype(System.ServiceModel.OperationContext.Current.Host.Description.Endpoints(0).Binding,System.ServiceModel.BasicHttpBinding).MaxReceivedMessageSize
65536

什么给了?

EDIT:这显然是服务器 web.config。我的客户端使用老式 SOAP Web 服务(wsdl.exe 代理)而不是 WCF 服务引用(svcutil.exe)来引用该服务。因此客户端在其 app.config 中没有 serviceModel 部分。以下是客户端拨打电话时发送的标头:

POST http://edocengine.localtest.me/services/templateMgr.svc HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.18052)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.edocbuilder.com/ItemplateMgr/setAssets"
Host: edocengine.localtest.me
Content-Length: 12192
Expect: 100-continue

编辑:找到answer,修改标题。

【问题讨论】:

  • 禁用 mex 后会发生什么?
  • 我的 web.config 中没有 mex。如果默认开启,如何禁用?
  • 尝试禁用这些行为,看看会发生什么。无论出于何种原因,它看起来都指的是其他东西。
  • 我注释掉了&lt;behaviors&gt;...&lt;/behaviors&gt; 并再次运行测试。不用找了。仍然以BasicHttpBinding 的身份出现。
  • 有端点(1)吗?

标签: vb.net wcf wcf-binding


【解决方案1】:

正如 SE 其他地方的回答:

You cannot consume service exposed on wsHttpBinding with default configuration by old ASMX proxy. 你必须要么使用添加服务 参考/svcutil 或将您的绑定更改为basicHttpBinding。 wsHttpBinding 的默认配置使用高级安全性和 ASMX 不支持。

所以,我想我需要回到 basicHttpBinding 并让它发挥作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-30
    • 2017-04-03
    • 1970-01-01
    • 2012-12-28
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多