0
我已經不運行的,我已經轉換爲使用自定義UserNamePasswordValidator一個窗口服務的WCF服務。WCF安全模式TransportWithMessageCredential
這一切都完美地工作在SECURITYMODE =「運輸」的原始設置。
但是唯一的問題是,沒有一個faultexceptions還會回來正常。 我猜測這是因爲它需要是TransportWithMessageCredential的安全模式。
我的問題是,當我設置的安全模式是現在TransportWithMessageCredential的UserNamePasswordValidator validate方法是打不到。
下面是我的app.config。任何建議將不勝感激。
謝謝。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<!-- hidden -->
</connectionStrings>
<system.serviceModel>
<services>
<service name="ThisApp.Global.Service.ServiceImpl" behaviorConfiguration="serviceBehaviour">
<host>
<baseAddresses>
<add baseAddress="https://testapi.ThisApp.com" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="ThisApp.Global.Service.IServiceImpl" />
</service>
</services>
<!--WCF Service Binding Configurations-->
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True"/>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="ThisApp.Global.Service.Security.AuthorizationPolicy, ThisApp.Global.Service" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ThisApp.Global.Service.Security.CustomUserNameValidator, ThisApp.Global.Service" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.diagnostics>
<trace autoflush="true" indentsize="2">
<listeners>
<add name="myListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="ThisApp Global API" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
感謝您的答覆。不幸的是這沒有什麼區別。任何嘗試訪問服務的結果都是:郵件無法處理。這很可能是因爲該操作不正確或者因爲消息包含無效或過期的安全上下文令牌或者因爲綁定之間存在不匹配。 – JIbber4568
上面還做了一個快速編輯,因爲這是作爲一個Windows服務運行,因此是一個app.config而不是web。乾杯 – JIbber4568
呵呵。我在做類似的事情。使用自定義身份驗證管理器與IIS託管服務進行basicHttp綁定。我需要的只是上面的配置。 –