Skip to main content

Java Client with WCF Service using wsHttpBinding and UserName credentials

6 replies [Last post]
Joined: 2009-08-04


I am new to Java. I am trying to develop a java client which can consume WCF web service (hosted on IIS).

Following is the summary of settings in WCF web service.
Binding = wsHttpBinding
Security Mode = Message
Client credentials = UserName

I want to supply user name and password dynamically inside the code.

I am using following environment
1. NetBeans IDE 6.5.1 (Build 200903060201)
2. GlassFish V3 Prelude (installed Metro Web service stack 1.4 using this link:
3. WCF Service using Microsoft Dot Net framework 3.5 (VS2008)

I have created certificate using makecert command and then imported in keystore using keytool.exe
[Referring this link:]

While running this in java client I am getting following errors

In java client
1. Client machine is different then server machine
The server sent HTTP status code 502: Proxy Error (The specified network name is no longer available.)

2. Client and server on same machine Connection reset Connection reset
In WCF Service log:
System.ServiceModel.ActionMismatchAddressingException, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

The SOAP action specified on the message, '', does not match the HTTP SOAP Action, ''.

The system works properly with .Net client but it is not working with java client.

I checked that it works if I use basicHttpBinding also but not working with wsHttpBinding.

I am attaching WCF server code and java client code. Could anyone please point my mistake?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-03-15

On the same machine, configure WCF tracing & logging and compare the request sent by the WCF and WSIT clients.

Web Services Security and Interoperability Blog

Joined: 2009-08-04

Hello Yaron,

Thanks for your reply. I have checked many of your previous articles in this regards.

I also tried comparing the message entries, but found that while running java client:
(1) Only entries related to query string=wsdl is logged.
(2) No new entry is created for action (which is created in case of .net client)

Further digging in this problem, I have done following changes.

Java Client
Started use of AddressingFeature in this way
org.tempuri.IService1 port = service.getWSHttpBindingIService1(new AddressingFeature(true,true));

WCF web.config:
Set establishSecurityContext="false"

Now I am getting following exception in java client

An error occurred when verifying security for the message. An error occurred when verifying security for the message.

I have also checked this link for the exception and confirmed that we are using V3:

But I could not understand this line “if we could change the SOAP to have “v3” instead of “v1” everything would have worked.”

Could you help me to solve this issue?

Thanks a lot

Joined: 2008-03-15

For the last error it seems some sort of a message was sent on the wire.
Vrify WCF logging is configured for logging both at service and transport levels.
You can also use a tool like Fiddler.
Also configure WCF trace so you can see any server side errors.
Web Services Performance, Interoperability And Testing Blog

Joined: 2009-08-04

Hello Yaron,

Thanks again for your reply.

I am still struggling with the issue. May be my knowledge about java and java certificate store is not accurate.

Is there any way where I can verify my JKS certificate with the windows certificate store certificate?

I have created certificate using makecert command and then imported in keystore using keytool.exe [Referring this link:]

Will that be possible for you to provide any link which contains working sample similar to my requirements?

Thanks a lot,

Joined: 2008-03-15

You need to understand what is exactly the error.

Configure WCF full logging and tracing and check the error and messages there.

Joined: 2012-04-03

Hi Yaron,

Looking for your help.
I need to consume WCF service(wsHttpBinding) enabled through jax-ws/axis
client. I tried with the proxy classes created through JAX-WS, got the error
message " An error occurred when verifying security for the message."

Service service = new Service(urlAddress);
IService iService = service.getWso2InteropBindingIService(new AddressingFeature(true, true));
BindingProvider bp = (BindingProvider) iService;

Thanks & Regards