NetWeaver using transaction code SM59 to create destination:
Java
Create a new destination:
Test code:
Try{Context CTX =NewInitialContext (); 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%sis not found. Hint: "+"Make sure to the destination configured.", Destinationname));return; }//Get the destination URLString value = destconfiguration.GetProperty("URL"); URL url =NewURL (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 responseInputStream instream = URLConnection.getInputStream(); OutputStream OutStream = Response.Getoutputstream();CopyStream(Instream, OutStream); }Catch(Exception e) {//Connectivity operation failedString errormessage ="Connectivity operation failed with reason:"+ E.GetMessage() +". See "+"logs for details. Hint:make sure to a 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); }
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