解决了我以前的问题之后,我想将netTcpBinding转换为一个customBinding,我成功管理了这个customBinding。但是,WcfTestClient(和普通客户端)在尝试提取元数据时发生错误,因为我将自定义授权策略置于正确的位置(它无需工作就可以正常工作!)。WCF CustomBinding - 无法通过自定义授权策略获取元数据
我的配置:
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="Sample.Tools.CustomAuthorizationPolicy, Sample" />
</authorizationPolicies>
我读过MSDN(这里:http://social.msdn.microsoft.com/Forums/en-IE/wcf/thread/80a33bc6-0765-45f6-8af5-0a414a5cc40d),由于还需要一个自定义的授权管理器,这可能会导致。我试过并添加了CustomAuthorizationManager(CheckAccessCore总是返回true),但它不起作用。
这在配置添加为:
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="Sample.Tools.CustomAuthorizationManager, Sample">
<authorizationPolicies>
<add policyType="Sample.Tools.CustomAuthorizationPolicy, Sample" />
</authorizationPolicies>
的配置的其余部分:
绑定:
<customBinding>
<binding name="SampleBinding" receiveTimeout="00:05:00">
<transactionFlow/>
<security authenticationMode="SecureConversation" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap authenticationMode="UserNameForSslNegotiated" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings maxClockSkew="23:59:59" />
<localServiceSettings maxClockSkew="23:59:59" />
</secureConversationBootstrap>
<localClientSettings maxClockSkew="23:59:59" />
<localServiceSettings maxClockSkew="23:59:59" />
</security>
<binaryMessageEncoding/>
<tcpTransport transferMode="Buffered" portSharingEnabled="true" maxReceivedMessageSize="65536" hostNameComparisonMode="StrongWildcard"/>
</binding>
</customBinding>
行为:
<behavior name="SampleBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpsHelpPageEnabled="true" />
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="Sample.Tools.CustomAuthorizationManager, Sample">
<authorizationPolicies>
<add policyType="Sample.Tools.CustomAuthorizationPolicy, Sample" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<serviceCertificate findValue="MySample" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Sample.Tools.CustomUserNameValidator, Sample" />
</serviceCredentials>
<serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
</behavior>
服务:
<services>
<service behaviorConfiguration="SampleBehavior"
name="Sample.SampleService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="SampleBinding"
name="MyServiceEndpoint"
contract="Sample.ISampleService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
bindingConfiguration=""
name="MyServiceMexTcpBidingEndpoint"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:809/SampleService.svc" />
</baseAddresses>
</host>
</service>
</services>
我几乎停留在这里,关于这个问题几乎没有发现。