ABAP和Java的destination和JNDI

來源:互聯網
上載者:User

標籤:reason   env   property   context   div   exce   tproxy   auto   分享   

Netweaver裡使用事務碼SM59建立Destination:

Java

建立一個destination:

測試代碼:

try {            Context ctx = new InitialContext();            ConnectivityConfiguration configuration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration");            DestinationConfiguration destConfiguration = configuration.getConfiguration(destinationName);            if (destConfiguration == null) {                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,                        String.format("Destination %s is not found. Hint:"                                + " Make sure to have the destination configured.", destinationName));                return;            }            // Get the destination URL            String value = destConfiguration.getProperty("URL");            URL url = new URL(value + "xml?origins=Walldorf&destinations=Paris");            String proxyType = destConfiguration.getProperty("ProxyType");            Proxy proxy = getProxy(proxyType);            urlConnection = (HttpURLConnection) url.openConnection(proxy);            injectHeader(urlConnection, proxyType);            // Copy content from the incoming response to the outgoing response            InputStream instream = urlConnection.getInputStream();            OutputStream outstream = response.getOutputStream();            copyStream(instream, outstream);        } catch (Exception e) {            // Connectivity operation failed            String errorMessage = "Connectivity operation failed with reason: "                    + e.getMessage()                    + ". See "                    + "logs for details. Hint: Make sure to have an HTTP proxy configured in your "                    + "local environment in case your environment uses "                    + "an HTTP proxy for the outbound Internet "                    + "communication.";            LOGGER.error("Connectivity operation failed", e);            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,                    errorMessage);        }

通過JNDI獲得destination配置的url:

要擷取更多Jerry的原創技術文章,請關注公眾號"汪子熙"或者掃描下面二維碼:

ABAP和Java的destination和JNDI

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.