creating a webservice in c# is easy… really… just click around in the visual studio and voila a new webservice 🙂 ok its a bit spooky, but who cares…
consuming a webservice is kinda spooky too… i tried to attach a webservice on a remote server and in my program to call the service i dont have a app.config… ok thats not true, but i wanted to call the service witout changing it all the time… therefore:
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;EndpointAddress remoteAddress = new EndpointAddress(<address>);
WebService1SoapClient ws= new WebService1SoapClient (binding, remoteAddress);
ws.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;