Error sending information to Webservice: System.ServiceModel.Security.Messagesecurityexception

Asked

Viewed 1,545 times

1

I created a simple web service that sums up two numbers and returns the result. O IIS left configured as windows authentication enabled and the other disabled.

Code:

  ServiceReference2.TesteSomaSoapClient a = new ServiceReference2.TesteSomaSoapClient();
  a.ClientCredentials.UserName.UserName = @ "Dominio\user";
  a.ClientCredentials.UserName.Password = "senha";

  var b = a.Soma(1, 1);

It’s made me wrong:

An unhandled Exception of type 'System.ServiceModel.Security.Messagesecurityexception' occurred in mscorlib.dll

Additional information: The HTTP request is not authorized in the 'Anonymous' client authentication scheme. The authentication header received from the server was 'Negotiate,NTLM'.

One more detail, I will not be able to send the user and password. It would have to catch the current user of who is calling the web service?

  • Put your Web.Config too.

  • The same thing that’s happening to you: 'System.ServiceModel.Security.Messagesecurityexception' in WCF

  • I have this <Binding> <security mode="Transportcredentialonly"> <transport clientCredentialType="Ntlm" proxyCredentialType="None" Realm="" /> <message clientCredentialType="Username" algorithmSuite="Default" /> </security> </Binding>

  • I got you guys

1 answer

0


I got you guys

        BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

        basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

        basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

        EndpointAddress endpoint = new EndpointAddress("http://localhost:81/GravaSolicitacao.asmx");

        ServiceReference2.GravaSolicitacaoSoapClient client = new ServiceReference2.GravaSolicitacaoSoapClient(basicHttpBinding, endpoint);

        client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

        client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

        //var xx = client.Soma(4, 3);
        var xx = client.GravaSolic(1, 1, 2);
  • Comment on your solution, please it is not clear what has changed in view that the code posted in the question is not complete and the code of your solution is totally different.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.