I created a webservice client with local wsdl using Metro 1.2 as follows:
./wsimport.sh -extension -verbose -wsdllocation service.wsdl -s src -d target service.wsdl -Xendorsed
Wsdl uses SOAP 1.2and wsHttpBinding. It must connect to the WCF server using NTLMas an authentication method.
I created Authenticatorto handle authentication NTLM:
public class NtlmAuthenticator extends Authenticator
{
private String username = "";
private String password = "";
public NtlmAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
}
which I set before each webservice method:
@WebEndpoint(name = "WSHttpBinding_ICustomerService")
public ICustomerService getWSHttpBindingICustomerService() {
ICustomerService service =
super.getPort(new QName("http://xmlns.example.com/services/Customer",
"WSHttpBinding_ICustomerService"), ICustomerService.class);
NtlmAuthenticator auth = new NtlmAuthenticator(username, password);
Authenticator.setDefault(auth);
return service;
}
If I use the wrong username / password, I get back 401 Unauthorizedback, which is fine and everything, but when I use the correct username / password, the call hangs and I never get an answer!
The request looks like this (captured using netcat, so the host is different and there is no https):
POST / HTTP/1.1
Content-type: application/soap+xml;charset="utf-8";action="http://xmlns.example.com/services/ICustomerService/GetCustomer"
Password: [password]
Authorization: Basic [auth]
Username: [username]
Accept: application/soap+xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.7-b01-
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:5500
Connection: keep-alive
Content-Length: 603
[xml follows]
wget 1.12 (, 1.11 NTLM), , .
[...]
---request end---
[writing POST file customerRequest.xml ... done]
HTTP request sent, awaiting response...
, , , . - ? JDK 1.6 Linux.