我需要对 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/