I'm consuming a WCF service not made by my company.

I need to have my WCF settings in code (no `.config` file modification).

With that in mind I'm trying to use a method in a plain Project with the settings in `Web.config` (generated by `Add Service Reference`) to test first. It does work.

```
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IIntegracao" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://wcf.mydomain.com.br/Integracao.svc/Integracao.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IIntegracao"
            contract="ServiceReference1.IIntegracao" name="WSHttpBinding_IIntegracao">
            <identity>
                <userPrincipalName value="user@mydomain.com.br" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

```

And I'm calling it like this:

```
using (var client = new ServiceReference1.IntegracaoClient())
{
    var resultado = client.Incluir(new Inclusao());
}

```

I continue my task removing all settings from `Web.config` and could'nt manage to make it work.

I even tried to leave the `Web.config` untouched and just inform it in the client constructor like this:

```
string url = ConfigurationManager.AppSettings["same url as above"];

var client2 = new IntegracaoClient(
            "WSHttpBinding_IIntegracao",
            new EndpointAddress(url));

var resultado2 = client2.Incluir(new Inclusao());

```

Didn't work

> 
> System.ServiceModel.Security.SecurityNegotiationException was
>  unhandled HResult=-2146233087 Message=SOAP security negotiation
>  with '<http://wcf.mydomain.com.br/Integracao.svc/Integracao.svc>' for
>  target
>  '<http://wcf.mydomain.com.br/Integracao.svc/Integracao.svc>'
>  failed. See inner exception for more details.
> 
> 
> InnerException: System.ComponentModel.Win32Exception
>  HResult=-2147467259
>  Message=Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account
>  with identity 'host/wcf.mydomain.com.br'. If the server is running in
>  a service account (Network Service for example), specify the account's
>  ServicePrincipalName as the identity in the EndpointAddress for the
>  server. If the server is running in a user account, specify the
>  account's UserPrincipalName as the identity in the EndpointAddress for
>  the server.
>  Source=System.ServiceModel
> 
> 
> 

My question is: Is the second call equivalent to the first one?

AS I understand the second call says to the client to use the same configuration used in the first call. Why does the second fail?