【问题标题】:WCF: strange automatic service referenceWCF:奇怪的自动服务参考
【发布时间】:2015-12-19 02:44:38
【问题描述】:

我使用 netHttp 绑定创建了一个简单的 WCF 服务,然后通过“添加服务引用|发现”将服务引用自动添加到另一个应用程序中。生成的绑定看起来很奇怪。

我得到的是CustomBinding,而不是原来的NetHttpBinding

它可以工作,但令人讨厌的是,我无法将 maxReceivedMessageSize 添加到自定义绑定中。

问题:有什么好的理由吗,或者我可以安全地用原始的 netHttpBinding 替换自定义绑定吗?

宿主的app.config:

  <endpoint address="images/netbh" binding="netHttpBinding" contract="WcfImageService.IImageService" bindingConfiguration="netHttp_bh" />

  <netHttpBinding>
    <binding name="netHttp_bh" messageEncoding="Binary">
      <webSocketSettings transportUsage="Never"/>
    </binding>
  </netHttpBinding>

客户端生成的app.config:

        <customBinding>
            <binding name="NetHttpBinding_IImageService1" >
                <binaryMessageEncoding />
                <httpTransport />
            </binding>
        </customBinding>

        <endpoint address="http://localhost:8080/images/netbh" binding="customBinding"
            bindingConfiguration="NetHttpBinding_IImageService1" contract="ImageServiceReference.IImageService"
            name="NetHttpBinding_IImageService1" />

我正在使用 Visual Studio 2015,以防万一。

【问题讨论】:

    标签: c# visual-studio wcf wcf-binding


    【解决方案1】:

    我不知道你为什么在客户端得到一个customBinding(我认为Visual Studio在后台使用的wsdl.exe工具有点混乱)但是你可以放心地将自定义绑定替换为原始的webHttpBinding。

    作为替代方案,我认为您也可以指定也可以在 元素上指定 maxReceivedMessageSize,如下所示:

    <httpTransport maxReceivedMessageSize="2000000000" />
    

    【讨论】:

    • 感谢您的确认以及将 maxReceivedMessageSize 添加到 httpTransport 的提示。它有效!
    猜你喜欢
    • 1970-01-01
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多