Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I can’t connect to my wfc, it is under SSL, but this is not a problem and I use custom authentication… and here starts my problems.

I connect to wfc:
ServiceReference1.Service1Client g = new ServiceReference1.Service1Client();
g.ClientCredentials.UserName.UserName = "a";
g.ClientCredentials.UserName.UserName = "b";
string a = g.GetData(77);

here my exception

System.ServiceModel.ServiceActivationException

WFC’s web.config is
HTML
<system.serviceModel>
    <services>
      <service name="WcfService1.Service1">
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="secureHttpBinding"
                  contract="WcfService1.IService1"/>

        <endpoint address="mex"
                  binding="mexHttpsBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>


          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <serviceCredentials>
            <userNameAuthentication  userNamePasswordValidationMode="Custom"
             customUserNamePasswordValidatorType="WcfService1.UsernameAuthentication, WcfService1" />
          </serviceCredentials>
</behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>


Class UsernameAuthentication is:

C#
namespace WcfService1
{
    public class UsernameAuthentication : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            var ok = (userName == "a") && (password == "b");
            ok = true;
            if (ok == false)
                throw new AuthenticationException(" not match");
        }
    }
}

My service is
C#
namespace WcfService1
{
        [ServiceContract]
    
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);
    }
}


can somebody help me?
thanks erika
Posted
Updated 24-Mar-14 4:53am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900