I've consumed a WebReference and the receiving server requires a WS-Security header:
<wsse:UsernameToken wsu:Id="Example"> <wsse:Username> ... </wsse:Username> <wsse:Password Type="..."> ... </wsse:Password> <wsse:Nonce EncodingType="..."> ... </wsse:Nonce> <wsu:Created> ... </wsu:Created> </wsse:UsernameToken> I'd assumed this would be included in the WSDL however after reading this post I understand that the logic should be separated.
The client class I use to perform the request contains a Proxy property IWebProxy:HttpWebClientProtocol. I believe this is where I should provide the header/override information. Please could someone confirm this?
I also have some code that I know generates the correct headers. However I'm unsure how to specify these headers/elements without modifying the WebReference.
public static Tuple<EndpointAddress, BindingElementCollection, string, string> PrepareGlowsAuth(string endpoint) { EndpointAddress soapEndpoint = new EndpointAddress(string.Format("{0}/{1}", (IsProduction ? productionBaseUrl : testingBaseUrl), endpoint)); BasicHttpsBinding binding = new BasicHttpsBinding(); binding.Security.Mode = BasicHttpsSecurityMode.TransportWithMessageCredential; binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; BindingElementCollection elements = binding.CreateBindingElements(); elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true; return new Tuple<EndpointAddress, BindingElementCollection, string, string>(soapEndpoint, elements, "username", "password"); } Would appreciate it if someone could point me in the right direction!
Update: After following advice I cant see the Client or Response classes.
