This article brings you a brief analysis of nodejs and Java services for accessing remote servers. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Since this article uses nodejs and Java to access remote server services, let’s first use another programming language, SAP’s ABAP (the programming language I use most in my daily work) to develop a service Bar.
This is the class I use to implement services in ABAP programming language: ZCL_DIS_HTTP_HANDLER
nodejs
##Look at the nodejs code.
The following code passes WANGJER into the Buffer as my username and 123456 as the password. The login method used is Basic Authentication.
var request = require('request'); var getTokenOptions = { url: "https://Execution results: It took a total of 1.4 seconds including network overhead.
java
WANGJER in the code below is my username and 123456 is the password. The login method used is Basic Authentication.
package connectivity; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.commons.codec.binary.Base64; import java.util.stream.Collectors; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; public class OPSystemConnectivity { static public void main(String[] arg){ final HttpGet get = new HttpGet("https://The execution result is almost as time-consuming as nodejs.
Note that the method introduced in this article can not only access the services of the remote server, but also achieve the goal of resource downloading: such as downloading pictures, mp3, etc. on a certain server. You only need to pass the URL of the corresponding resource into the system.
Copy after login
The above is the detailed content of A brief analysis of nodejs and Java access to remote server services. For more information, please follow other related articles on the PHP Chinese website!