2010-03-24 4 views
1

J'ai créé un service wcf avec sécurité de transport sur HTTPS. De plus, j'utilise l'authentification UserName comme décrit au http://msdn.microsoft.com/en-us/library/cc949025.aspx, donc je peux utiliser mon Membership, RoleProvider. Quand je travaille avec ce service avec ASP.NET tout est OKWCF (HTTPS, NomUtilisateur) appelant par SilverLight

var client = new RegistratorClient(); 
    client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["registratorLogin"]; 
    client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["registratorPassword"]; 

Mais à mon appliation SilverLight Je ne peux pas faire la même chose. Lorsque j'essaie d'installer des credntials et d'appeler wcf, j'obtiens une fenêtre de navigateur standard avec un nom d'utilisateur et un mot de passe. Quand je l'insère, l'application SL fonctionne bien, mais ce message est tellement ennuyeux. Je ne peux pas utiliser clientCredentialType = "Basic" dans ma configuration SL.

Que dois-je faire pour appeler mon WCF en silence?

Un grand merci

+0

Pourriez-vous s'il vous plaît poster vos liaisons nœud de votre web.config. Nous pouvons donc voir comment basicHttpBinding est configuré? - Merci – DaveB

Répondre

0

Utilisez-vous basicHttpBinding? et sont l'application sl et svc sur le même domaine?

J'ai (je pense) une configuration similaire - silverlight 3.0/wcf hébergé sur https en utilisant l'authentification par formulaire. Je vais copier dans toutes mes configs connexes, au cas où vous manquez quelque chose.

ServiceReferences.ClientConfig (a dû enlever l'étiquette de 'configuration', sinon le bloc entier disparaît):

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_PassportService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" 
       textEncoding="utf-8"> 
       <security mode="Transport"> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://domain/service.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PassportService" 
      contract="PassportService.PassportService" name="BasicHttpBinding_PassportService" /> 
    </client> 
</system.serviceModel> 

ServiceModel dans web.config:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="ProjectPassport.Web.PassportServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpGetUrl="http://domain/service.svc" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
       <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="basicHttpsBinding"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None"/> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <services> 
     <service behaviorConfiguration="ProjectPassport.Web.PassportServiceBehavior" 
     name="ProjectPassport.Web.PassportService"> 
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" 
       contract="ProjectPassport.Web.PassportService" /> 
     </service> 
    </services> 
</system.serviceModel> 

et mon authentification/autorisation/configuration d'appartenance:

<authentication mode="Forms"> 
     <forms loginUrl="Home.aspx" protection="All" timeout="80" name="AppName" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Manage.aspx" cookieless="UseCookies" enableCrossAppRedirects="false"/> 
    </authentication> 

    <authorization> 
     <deny users="?"/> 
     <!----> 
     <allow users="*"/> 
    </authorization> 
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"> 
     <providers> 
      <clear/> 
      <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" applicationName="MyApplication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="50" passwordStrengthRegularExpression=""/> 
     </providers> 
    </membership> 

également, n'oubliez pas que js/clientBi Les emplacements de service n/wcf devraient être autorisés. ajouter des balises de localisation:

<location path="ClientBin"> 
    <system.web> 
     <authorization> 
      <allow users="*"/> 
     </authorization> 
    </system.web> 
</location> 
<location path="service.svc"> 
    <system.web> 
     <authorization> 
      <allow users="*"/> 
     </authorization> 
    </system.web> 
</location> 

etc ...

Edit: ce lien, vous faites référence à est ciblé à WinForms. Si je ne me trompe pas, vous construisez une application Silverlight 3. un coup d'oeil à ces lieu:

http://msdn.microsoft.com/en-us/library/dd560704%28VS.95%29.aspx

http://www.eggheadcafe.com/tutorials/aspnet/7cc2760f-50f2-492d-9d62-48ad5c7f70b4/aspnet-membership-and-ro.aspx