我有一个WCF REST服务,该服务必须接受来自客户端的原始输入流。为了接收原始流,我在web.config文件中使用了自定义绑定。如果我将其设置为通过标准HTTP连接,则该服务可以正常运行。但是,我很难让它通过HTTPS工作。
消息级别的安全性不支持手动寻址。配置绑定(“ CustomBinding”,“ http://tempuri.org/”)以使用传输安全性或不执行手动寻址。
以下是我用于HTTP的配置:
<service behaviorConfiguration="LocalBehavior" name="RestService.CreditService">
<endpoint address="" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" contract="RestService.ICreditService" />
</service>
<behavior name="LocalBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000"
transferMode="Streamed" />
</binding>
这是我用于HTTPS的配置:
<service behaviorConfiguration="SecureBehavior" name="RestService.CreditService">
<endpoint address="basic" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" name="httpsEndpoint" contract="RestService.ICreditService" />
<host>
<baseAddresses>
<add baseAddress="http://sitcreditserviceszalecorp.cloudapp.net:3389/CreditService.svc" />
<add baseAddress="https://sitcreditserviceszalecorp.cloudapp.net:443/CreditService.svc" />
</baseAddresses>
</host>
</service>
<behavior name="SecureBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<security authenticationMode="CertificateOverTransport"
requireSecurityContextCancellation ="true">
</security>
<httpsTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" authenticationScheme="Anonymous" requireClientCertificate="false" />
</binding>
谁能指出我做错了什么?谢谢。
最佳答案
在遇到一篇文章建议删除安全元素之前,我遇到了同样的问题。那对我有用。
关于web-services - 具有自定义绑定(bind)的WCF REST服务的SSL配置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34761443/