Netweaver里使用事务码SM59创建Destination:

Java
新建一个destination:


测试代码:
1try { 2 Context ctx = new InitialContext(); 3 ConnectivityConfiguration configuration = (ConnectivityConfiguration) ctx.lookup("java:comp/env/connectivityConfiguration"); 4 5 DestinationConfiguration destConfiguration = configuration.getConfiguration(destinationName); 6 7 if (destConfiguration == null) { 8 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 9 String.format("Destination %s is not found. Hint:" 10 + " Make sure to have the destination configured.", destinationName)); 11 return; 12 } 13 14 // Get the destination URL 15 String value = destConfiguration.getProperty("URL"); 16 URL url = new URL(value + "xml?origins=Walldorf&destinations=Paris"); 17 18 String proxyType = destConfiguration.getProperty("ProxyType"); 19 Proxy proxy = getProxy(proxyType); 20 21 urlConnection = (HttpURLConnection) url.openConnection(proxy); 22 23 injectHeader(urlConnection, proxyType); 24 25 // Copy content from the incoming response to the outgoing response 26 InputStream instream = urlConnection.getInputStream(); 27 OutputStream outstream = response.getOutputStream(); 28 copyStream(instream, outstream); 29 } catch (Exception e) { 30 // Connectivity operation failed 31 String errorMessage = "Connectivity operation failed with reason: " 32 + e.getMessage() 33 + ". See " 34 + "logs for details. Hint: Make sure to have an HTTP proxy configured in your " 35 + "local environment in case your environment uses " 36 + "an HTTP proxy for the outbound Internet " 37 + "communication."; 38 LOGGER.error("Connectivity operation failed", e); 39 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 40 errorMessage); 41 }
通过JNDI获得destination配置的url:

要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

