Skip to Content
avatar image
Former Member

Not able to connect to SAP ABAP system using java Application

Hi all,

I have a java spring boot application deployed in CP which is trying to connect to SAP ABAP system.

Everytime, I am getting 502 error. Also, using postman Im able to access the end url but not with java application.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 26, 2018 at 09:12 AM


    Finally succeeded in getting the response.

    List of changes :

    1. Connect to HTTPUrlConnection via proxy

    Proxy proxy = getProxy(proxyType);

    (HttpURLConnection) url.openConnection(proxy)

    //To get the proxy host and proxy port..

    private Proxy getProxy(String proxyType) { String proxyHost = null; int proxyPort; if (ON_PREMISE_PROXY.equals(proxyType)) { // Get proxy for on-premise destinations proxyHost = System.getenv("HC_OP_HTTP_PROXY_HOST"); proxyPort = Integer.parseInt(System.getenv("HC_OP_HTTP_PROXY_PORT")); } else { // Get proxy for internet destinations proxyHost = System.getProperty("http.proxyHost"); proxyPort = Integer.parseInt(System.getProperty("http.proxyPort")); } logger.error(proxyHost + " : proxy port " + proxyPort); return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); }

    2. Add the "SAP-Connectivity-ConsumerAccount" header in the connection .

    TenantContext tContext = null;

    tContext = (TenantContext) temp.lookup("TenantContext");

    connection.setRequestProperty("SAP-Connectivity-ConsumerAccount", URLManager.tContext.getAccountName());

    Feel free to contact me in case you did not understand...

    Add comment
    10|10000 characters needed characters exceeded