I am updating an older tool that we have been using for over 10 years that is similar to SoapUI, but C# based. The original code is using this function to connect to a WCF web service and download the WSDL information:
DiscoveryClientProtocol discoveryClientProtocol = new DiscoveryClientProtocol();
discoveryClientProtocol.AllowAutoRedirect = true;
discoveryClientProtocol.UseDefaultCredentials = true;
discoveryClientProtocol.DiscoverAny(serviceDescriptionURL.URL);
discoveryClientProtocol.ResolveAll();
We recently migrated our WCF web services to the cloud and I need to be able to send an authentication header with all requests to the URL. I know that DiscoveryClientProtocol is inherited from HttpWebClientProtocol and WebClientProtocol, but so far I haven't figured out how to modify the code in order to include a header.
I have tried playing with the CookieContainer() collection to see if adding a System.Net.Cookie would translate to an authentication header, but so far all attempts to add the cookie have failed with various error messages. I don't know if this is the correct path to go down.
I also have captured my traffic using Fiddler and can see that the request is running into the expected authentication error. If I rerun the request in Fiddler with the proper header, it works fine. I just need to understand if there is a way to add that header programmatically.
Is this possible? If so, what do I need to do to add a header or authentication?
Thanks in advance!