Consuming a SOAP Web Service with Basic Authentication in C#
Interacting with SOAP web services, such as those built with PHP, from a .NET application is a common task. When these services are protected by HTTP Basic Authentication, configuring the C# client requires a small extra step, but it’s simpler than it might seem. This guide demonstrates the standard and recommended method for consuming a secure SOAP web service with Basic Auth using C#. The Challenge: Basic Authentication When you add a “Service Reference” to a Visual Studio project for a SOAP web service, the generated client doesn’t automatically handle sending authentication credentials. If you try to call a service method directly, you will likely get a (401) Unauthorized error. ...