C# .NET - Consume Java WebService with digest authentication from C Sharp

Asked By mauricio arias on 25-Aug-08 04:45 PM

Hello Everybody

I have to consume a web service in java, it uses a digest authentication. I wrote this code using a proxy class in .net 2008

WSJava1.MyWebServiceWSClient ws2 = new ClientWS.WSJava1.MyWebServiceWSClient();
ws2.ClientCredentials.HttpDigest.ClientCredential = new System.Net.NetworkCredential("user", "1234", "mydomain.com");
ClientWS.WSJava1.ObjRequestDTO request = new ClienteWS.WSJava1.ObjDTO();
request.numTransaction =
request.mount =
ClienteWS.WSJava1.ResponseDTO response;
response = ws2.doOperation(request);

and I get the exception message: Missing <wsse:Security> SOAP Header.
Any suggestion?

In order to comply with the wsse header that's it's requiring - Peter Bromberg replied to mauricio arias on 25-Aug-08 06:31 PM

you will most likely have to switch to a WCF Service reference. There are a lot more settings. "wsse" covers the ws-security specification. There was (is) an add-on for VS2005 called "WSE Extensions" but since this is built into WCF in VS 2008, that's what you need to use.

Try this - ram kumar replied to mauricio arias on 25-Aug-08 08:11 PM


The Soap message that is transfered from the client to server actually has all the required SOAP headers. I was retrieving the message at the wrong place.

The runtime executes in the following order :

1)  Creating the SOAP message from the proxy object.

2)  Executing the SOAP extension if one exists.

3) Runs the WSE filters on the SOAP message to add the required headers depending on the  objects present in SoapContext.

Since I was looking at the soap message from the second step, the header were not added.

The correct method to retrive SOAP message is using the WSE settings tool.

1) Right  click on the project and select "WSE Settings"

2) Select the Diagnostics tabs and check "Enable Message Tracing". The 'input file' and 'output file' has the final SOAP Request and SOAP Response messages.

Once again, this is a copy-paste job. - Peter Bromberg replied to ram kumar on 25-Aug-08 09:13 PM


You have not addressed the fact that the OP is using Visual Studio 2008.

It is easy to answer questions with "something". It is not easy to completely understand what the poster is asking for and to be able to respond with an  answer that is more intelligent than searching for external content and posting it as an answer.

Issue... - Atul Shinde replied to mauricio arias on 26-Aug-08 01:13 AM
U must specify the SOAP Header while using JAVA Web Service into .NET.
Switch to WSE - mauricio arias replied to Peter Bromberg on 26-Aug-08 10:52 AM

Hi everybody, I decided to use WSE  3.0  with vs 2005 (i think is more easy) and modify the code like this

wsjava.GatewayPrepayWSWse ws = new MyProject.wsjava.GatewayPrepayWSWse();

//Creates the username/password digest token

Microsoft.Web.Services3.Security.Tokens.UsernameToken userToken = new


//Creates web service credentials using the token

Microsoft.Web.Services3.Security.CredentialSet credentials = new Microsoft.Web.Services3.Security.CredentialSet(userToken);

//Assigns the username/password to the web services proxy



wsjava.CreditRequestDTO request = new Definitiva.wsjava.EpinCreditRequestDTO();

wsjava.CreditResponseDTO response;

request.mount = "200000";

request.numTransaction = "222";

response = ws.epinCredit(request);

But now i get the exception The Security token could not be authenticated or authorized 

I appreciate  your commentaries, thanks for your help