带有 CustomBinding 的 WCF 服务配置 HTTPS

标签 wcf https wcf-binding basic-authentication transport

我需要对 WCF 服务进行自定义绑定(bind),以允许我将原始内容传递给 WCFRest 服务。效果很好,但我无法让它接受传输级别的安全性。我想要 https 和 basicauthentication,就像我在其他地方使用的一样。端点如下所示:

   <endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>

customBinding 看起来像这样:
  <customBinding>
    <binding name="RawReceiveCapable">
      <security mode="Transport">
        <transport clientCredentialType="Basic"/>
      </security>
      <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
    </binding>
  </customBinding>

但系统提示安全节点中不允许使用模式属性。没有安全节点,一切都很好,但它不是 https。

谢谢

射线

最佳答案

我认为您需要删除 <security>元素,然后将 httpTransport 元素更改为 httpsTransport,如下例所示:

<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="RawReceiveCapable">
              <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
              <httpsTransport authenticationScheme="Basic"  manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
            </binding>
        </customBinding>
    </bindings>

以下链接可能会有所帮助:
http://msdn.microsoft.com/en-us/library/ms731818.aspx

关于带有 CustomBinding 的 WCF 服务配置 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19232445/

相关文章:

wcf - 在 BizTalk 中禁用 WCF 自签名证书验证

c# - WCF WebInvoke JSON 反序列化失败 - 400 错误请求

通过 https 的 Java Web 服务 - 如何将自签名证书添加到客户端 api 中?

wcf - 如何覆盖 WebServiceHostFactory MaxReceivedMessageSize?

tcp - 无需任何 KeepAlive() 方法的 TCP 持久双工

c# - Entity Framework - 底层提供程序在 ConnectionString 上失败

wcf - 在 web.config 中配置 wcf Rest 服务

Android HTTPS 异常连接由对等方重置

rest - http-headers 和 http-body 之间有什么安全区别吗?

WCF REST 和 asp.net 以及调试