Destination and Jndi for ABAP and Java

Source: Internet
Author: User

NetWeaver using transaction code SM59 to create destination:

Java

Create a new destination:

Test code:

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 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.GETINP            Utstream ();            OutputStream OutStream = Response.getoutputstream ();        CopyStream (instream, OutStream); } catch (Exception e) {//Connectivity operation failed String errormessage = "Connectivity Operati On failed with reason: "+ e.getmessage () +". See ' + ' logs for details. Hint:make sure to a HTTP proxy configured in your ' + ' local environment in case your environmen            T uses "+" an HTTP proxy for the outbound Internet "+" communication. ";            Logger.error ("Connectivity operation failed", E);        Response.senderror (Httpservletresponse.sc_internal_server_error, errormessage); }

Get the URL for the destination configuration via Jndi:

To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:

Destination and Jndi for ABAP and Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.