configuring the http proxy in weblogic

To configure the proxy in weblogic configure the below properties in setDomainEnv:

-DproxySet=true
-Dweblogic.webservice.transport.http.proxy.host=proxy
-Dweblogic.webservice.transport.http.proxy.port=80
-Dweblogic.webservice.transport.https.proxy.host=proxy
-Dweblogic.webservice.transport.https.proxy.port=80
-Dhttp.proxyHost=proxy
-Dhttp.proxyPort=80
-Dhttp.nonProxyHosts="172.16.40.84|172.16.40.63"
-Dhttps.proxyHost=proxy
-Dhttps.proxyPort=80
-Dhttps.nonProxyHosts="172.16.40.84|172.16.40.63"

If the proxy is accepting username/password
Or if you face the below issue,
weblogic.net.http.HttpUnauthorizedException: Auth scheme Negotiate is not supported!
then you may need to write the custom authenticator for calling the service behind proxy.

Please find the below example for custom proxy authenticator:

Write the class that extends java.net.Authenticator.
***
import java.net.Authenticator;
import java.net.PasswordAuthentication;

public class ProxyAuthenticator extends Authenticator {
    private String username;
    private String password;
    public ProxyAuthenticator(String username, String password){
        this.username = username;
        this.password = password;
    }
    public PasswordAuthentication getPasswordAuthentication () {
        return new PasswordAuthentication (username, password.toCharArray());
    }

}
***

From your code, before calling the service over the http set the above authenticator.

//I set the proxy again for safer side
System.setProperty("http.proxyHost", "proxy");            
System.setProperty("http.proxyPort", "80");
System.setProperty("https.proxyHost", "proxy");            
System.setProperty("https.proxyPort", "80");

Authenticator.setDefault (new ProxyAuthenticator("username","password"));


Reference Documents:

https://docs.oracle.com/cd/E13222_01/wls/docs81/webserv/client.html (Using a Proxy Server with the WebLogic Web Services Client)
https://docs.oracle.com/cd/E24329_01/web.1211/e24967/client.htm#WSRPC215
http://soadev.blogspot.com/2010/02/setting-proxy-authentication-in-java.html

Popular posts from this blog

JAVA embedding in Oracle SOA 12c

Passing/Receiving HTTP header in SOA BPEL

Integrating Weblogic with IBM MQ over JMS