سؤال

I have generated a Web Serice client stub from a WSDL file using WSConsume. The Generated stub is then used in Client code to send data to the web service.

This all works fine. i.e. The client is able to communicate to web service and exchange data and everything.

My problem starts as soon as the Client is deployed behind a Proxy. I have got most of this sorted out as well. What we do is to set following JVM properties when the client starts.

http.proxyHost, http.proxyPort, https.proxyHost and https.proxyPort

I understand that this is not suggested and in time we will move to ProxySelector. But for now this works for us as long as Proxy does not need authentication.

To solve the authentication issue I did override the default PasswordAuthentication

Authenticator.setDefault(new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(httpsProxyUser, httpsProxyPassword.toCharArray());
    }
});

This too works well is most of the case. I understand that this is what is generally called NTLM authentication.

My nightmare starts when the Proxy is expecting Basic authentication. From what I have understood so far is that for this authentication mechanism to work we need to set Proxy-Authorization header in request property. Which again can be done easily if I have access to HTTP Client object.

But how to do this when using a Stub which is generated via wsconsume?

هل كانت مفيدة؟

المحلول

One way to do this is to use following JVM option. This one worked for me.

-Dhttp.auth.preference="basic"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top