Implement Communication VIA HTTP

profilenettyjames
order_146570_391702.docx

5

Implementation of Communication Via HTTP

Student’s Name

Course

Institutional Affiliation

Date

Implementation of Communication Via HTTP

Introduction

In distributed computing, large-scale data processing using different applications such as web-based is mostly done using multiple interlinked computers via the internet. In the web-based applications, the communication is implemented using HyperText Transfer Protocol (HTTP), which is well known for providing the communication between the browser and web server (Belshe et al., 2015). The messages to be communicated between computers comprises sequences of bytes. For the communication between the web browser and web server to occur, the web server provides the necessary communication to occur via the browser. Understandably, HTTP is known to be an application-level protocol for hypermedia and distributed information systems. Additionally, communication via HTTP is mostly applied for distributed information systems, whereby communication response caches are applied to improve application performance. This paper aims to discuss the implementation of communication via HTTP in payment processing systems.

HTTP Communication in Payment Processing

In payment processing, the communication between objects representing payment requests involves using HTTP to transmit payment information such as credit card information and the amount paid. The first thing in HTTP communication is to verify and validate the credit card's authorization and the requested amount. When the customer side triggers the action, the company receives an acknowledgment and will verify the payment's success. The status code is sent via HTTP or an error code if the payment was not successful. Additionally, it is possible to track the server and error logs, which help the company trace the transactions' success. During the payment processing, HTTP error does occur; however, this can be easily rectified. These errors can occur to any of the following methods: POST, GET, GET, or DELETE. In the GET method, the error may occur while trying to fetch a resource. Whenever the client initiates a request via the web browser or any other application, the server responds using the status code and the message payloads. In HTTP communication, the status code is paramount as it provides information to the client on how to respond to the server's request.

Implementation of Communication Via HTTP in Java

Notably, the implementation of the communication via HTTP can be done using Java programming language. In this case, implementation can be done using Representation State Architecture (REST), a standard architecture for distributed systems. With this architecture, the resources need to be identified, where such resources are manipulated via the standard interfaces, including the use of HTTP (Hu et al., 2008). The software resources required to implement HTTP in a distributed computing include Netbeans, Java Development Kit (JDK), Java-EE compliant application server, Java Database, or MSQL server.

Understandably, network programming involved in the implementation of communication via HTTP is all about writing a code that can execute id different computers connected over the network. The use of java.net package with J2SE APIs comprises interfaces and classes that offer low-level communication details, thus facilitating the writing of programs geared to provide a solution to the problem at hand. The java.net package offers support of different network protocols such as HTTP and TCP. Ideally, when the connection is established between different objects, especially in payment processing, the server(s) create a socket object at the end of the communication. This facilitates the communication between the objects through writing to and reading from the object.

The initial step in initiating HTTP/2 protocol response via Java is through the HTTP upgrade header. Notably, the begins by making an explicit text request which can be modified and upgraded to HTTP/2 protocol. Implementation of HTTP also requires the use of an HTTP/ 2 server that is compatible and that can be easily upgraded through switching protocols response. The code below shows the configuration of the upgrade HTTP request and switching protocols HTTP response in a distributed computing environment.

Upgrade HTTP request in Java

Switching Protocols HTTP response in Java.

Ideally, in HTTP communication in Java, the code for HTTP socket is handled by java.net. Socket . The code below is used in opening the connection to the server; this connection is the one that establishes the communication using HTTP.

Socket socket=new Socket (Server, port);

Upon establishing the socket connection, the server, whatever that follows, is to obtain input and output stream to the server. The input stream's main goal in the HTTP connection in Java is to read data to the server, whereas output streams are to write data to the server. This can be presented using the code excerpt below.

InputStream in= socket.getInputStream();

OutputStream out = socket.getOutputStream();

While sending the requests using the HTTP URL connection, it requires adding some items like the headers and authentication. This can also be configured by relying on libraries like Apache-Commons. HttpURLConnection is the Java main class that is used to handle HTPP requests and responses. In case of implementing HTTP in a distributed. The sample code below is used to show the instantiation of the HttpURLConnection object via URL. To establish the HTTP communication, we have used a sample site via this link/ URL https://www.englishclub.com/.

The primary HTPP request type involved in distributed computing is POST, and GET. However, other HTTP types or methods that can be applied include DELETE, TRACE, OPTIONS, PUT, and HEAD, as captured in the screenshot below.

The HTTP request in payment processing to work effectively requires specific query parameters, which can be initialized using HashMap, as shown in the screenshot below.

Implementation of communication via the HTPP Post method can be implemented, as shown in the screenshots below. Additionally, the code generates the POST request, transmit it, and then read the response. This code has been implemented in JAVA using NetBeans IDE version 12.1.

For the establishment of an HTTP connection, it requires a secure connection, which can be implemented via SSL. Ideally, the implementation of HTTP communication requires a daemon that runs continuously in the HTTP socket. This daemon is always enabled even when the server is started or restarted. The main goal of SSL is to provide a secure connection over the computer network. It is important to note that the HTTPS communication protocol is implemented using SSL, which requires configuration of three main files: .crt file, .csr file, and .key file. The certificate generated is hashed or encrypted to ensure that the communication and connection remain secure throughout. Configuration and setting up SSL in JAVA can be implemented, as shown in the diagram below.

Conclusion

HTTP is critical in the communication of multiple computers in a network in a distributed computing environment. In a web client and web server environment, HTTP's use to facilitate communication is made a reality as this is an application-level protocol for hypermedia and distributed information systems. As discussed in this paper and based on the practical implementation of communication via HTTP, it can be argued that HTTP forms the foundation of data communication via the web server and the world wide web in general. This paper has depicted how the implementation of communication between the objects via HTTP.

Bibliography

Belshe, Mike, Roberto Peon, and Martin Thomson. "Hypertext transfer protocol version 2 (http/2)." (2015).

Hu, Raymond, Nobuko Yoshida, and Kohei Honda. "Session-based distributed programming in Java." In European Conference on Object-Oriented Programming, pp. 516-541. Springer, Berlin, Heidelberg, 2008.

Podila, Pavan. HTTP: The Protocol Every Web Developer Must Know - Part 1. Retrieved from https://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177. (2013)