2013-05-30 3 views
2

Le scénario est le suivant: J'ai deux machines de bureau:WCF Erreur

  1. WCF service hébergé sur la machine de bureau ABC.
  2. Application de console créée sur CDE Desktop.

Lorsque j'essaie de me connecter à mon service WCF avec l'application console, j'obtiens une erreur Logon Attempt Failed.

service WCF (web.config)

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="IISHost.Service1Behavior" name="IISHost.Service1"> 
     <endpoint address="" binding="wsHttpBinding" contract="IISHost.IService1"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service behaviorConfiguration="IISHost.IISHostBehavior" name="IISHost.IISHost"> 
     <endpoint address="" binding="wsHttpBinding" contract="IISHost.IIISHost"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="IISHost.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     <behavior name="IISHost.IISHostBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

Application console (app.config)

<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_IIISHost" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" 
        hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" 
           maxArrayLength="16384" maxBytesPerRead="4096" 
           maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="Message"> 
         <transport clientCredentialType="Windows" /> 
         <message clientCredentialType="Windows" 
           negotiateServiceCredential="true" algorithmSuite="Default" 
           establishSecurityContext="true" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://yogeshpc/IISHost/IISHost.svc" 
         binding="wsHttpBinding" 
         bindingConfiguration="WSHttpBinding_IIISHost" 
         contract="ServiceReference1.IIISHost" 
       name="WSHttpBinding_IIISHost"> 
       <identity> 
        <dns value="localhost" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

Application console (fichier .cs)

static void Main(string[] args) 
     { 
      var d = new IISHostClient(); 
      d.ClientCredentials.Windows.ClientCredential.UserName = "YOGESH"; 
      //d.ClientCredentials.Windows.ClientCredential.Domain = "Workgroup"; 
      d.ClientCredentials.Windows.ClientCredential.Password = "[email protected]"; 
      d.ClientCredentials.Windows.AllowNtlm = false; 
      Console.WriteLine(d.add(30, 30)); 
      Console.ReadLine(); 
     } 

Note: UserName et mot de passe utilisé dans la console Le fichier CS d'application est A BC Desktop machine Nom d'utilisateur et mot de passe locaux.

Répondre

2

Je pense que vous manquez une configuration pour votre fixation sur le service Web:

<bindings> 
<wsHttpBinding> 
    <binding name = "someNameForTheBinding"> 
    <security mode="Message"> 
     <message clientCredentialType="Windows"/> 
    </security> 
    </binding> 
</wsHttpBinding></bindings> 

Vous pouvez vérifier plus sur ce here.

+0

son là dans l'application de la console (de app.config), s'il vous plaît vérifier code ci-dessus (Application console (app.config)) pour le même. – John

+0

Vous devez également l'ajouter sur le serveur. – lex87