2014-06-10 70 views
0

我需要WCF的幫助!wsHttpBinding與自定義自動化,證書認證和消息傳輸安全

我用自定義授權和認證編寫了WCF服務。服務從Visual Studio啓動時運行良好,但是當我從任何主機(由我創建的Windows服務或主機)啓動時 - 引發下一個異常:

「收到來自無擔保或錯誤安全的故障另一方,查看故障代碼和細節的內部FaultException。「

內部異常:

「的消息驗證安全性時發生錯誤。」

服務配置(它的配置我複製到宿主app.cong):

<system.serviceModel> 

    <!--Binding with custom authentication--> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="licenseServiceBinding"> 
      <security mode="Message"> 
      <message clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

    <services> 
     <service name="NS_SLM_Service.Service.LicenseService" behaviorConfiguration="customBehaviour"> 

     <!--One service devided by a few contracts, because on a client need to separate API-functions--> 

     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="licenseServiceBinding" contract="NS_SLM_Service.Service.IAdminFunctions" /> 

     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="licenseServiceBinding" contract="NS_SLM_Service.Service.IManagerFunctions" /> 

     <endpoint address="http://localhost:8080/LicenseService/CommonFunctions" binding="basicHttpBinding" contract="NS_SLM_Service.Service.ICommonFunctions" /> 

     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8080/LicenseService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="customBehaviour"> 
      <serviceMetadata httpGetEnabled="True" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 

      <serviceAuthorization principalPermissionMode="Custom"> 
      <authorizationPolicies> 
       <add policyType="NS_SLM_Service.UserAuthorization,NS_SLM_Service" /> 
      </authorizationPolicies> 
      </serviceAuthorization> 

      <serviceCredentials> 
      <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="NS_SLM_Service.UserAuthentication,NS_SLM_Service" /> 
      <serviceCertificate findValue="tempCert" storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="My" /> 
      </serviceCredentials> 

     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

下一個代碼試圖連接到這個服務:

using (var proxy = new MyService()) 
       { 
        proxy.ClientCredentials.UserName.UserName = "Login"; 
        proxy.ClientCredentials.UserName.Password = "password"; 

        proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 

        proxy.SomeMethod("Parametr"); 
       } 

我感到沮喪,因爲當我嘗試連接服務,當它在VS啓動,我沒有看到任何豁免...

回答

0

因爲你內部的異常信息不是很精確,我會開始從enab調查記錄這將會產生詳細的信息,確切地說錯了什麼。

你可以找到示例配置在這裏: http://msdn.microsoft.com/en-us/library/ms733025.aspx

對於瀏覽記錄,你可以從SDK使用SvcTraceViewer.exe工具。

+0

謝謝。它可以幫助我。 –

相關問題