SCENARIO
I have to access a web service with a .NET client. The service is an Apache CXF Web Service. Username and password authentication is required. I have created the proxy. I have set up the credential.
MyServiceReference proxy = new MyServiceReference();
proxy.Credentials = new NetworkCredential("username", "password");
string res = proxy.Method1();
When I run the client, the following exception is thrown:
System.Web.Services.Protocols.SoapHeaderException: An error was discovered processing the <wsse:Security> header
The service publisher told me that the credentials are not present in the SOAP headers. So, I guess that IWebProxy.Credentials is not the correct way to set up the authentication.
QUESTION
So, how can I set up the SOAP header required for the authentication?
Eventually I had to invoke the service creating the whole SOAP message and making an
HttpWebRequest
. In the SOAP message I manually specify the security header:And here the service client:
Interesting resources about Web Service Security (WSS):