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