Metro client freezes when calling WCF web server using wsHttpBinding

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.

+5
1

, , Addressing getPort super:

WebServiceFeature wsAddressing = new AddressingFeature(true);

ICustomerService service =
    super.getPort(new QName("http://xmlns.example.com/services/Customer",
            "WSHttpBinding_ICustomerService"), ICustomerService.class, 
            wsAddressing);

, . :

@WebEndpoint(name = "WSHttpBinding_ICustomerService")
public ICustomerService getWSHttpBindingICustomerService() {
    WebServiceFeature wsAddressing = new AddressingFeature(true);

    ICustomerService service =
        super.getPort(new QName("http://xmlns.example.com/services/Customer",
                "WSHttpBinding_ICustomerService"), ICustomerService.class, 
                wsAddressing);

    NtlmAuthenticator auth = new NtlmAuthenticator(username, password);  
    Authenticator.setDefault(auth);   

    return service;
}

, , SOAP:

<S:Header>
  <To xmlns="http://www.w3.org/2005/08/addressing">https://services.example.com/CustomerService.svc</To>
  <Action xmlns="http://www.w3.org/2005/08/addressing">http://xmlns.example.com/services/ICustomerService/GetCustomer</Action>
  <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
    <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
  </ReplyTo>
  <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:d33c2888-abfa-474d-8729-95d2bcd17a96</MessageID>
</S:Header>
+3

All Articles