Sunday, September 30, 2018

WEB SERVICES


There is more than one way to answer: "What is a web service?", But essentially, Web services include any software, application or cloud technology that provides standardized Web protocols (HTTP or HTTPS) to interoperate, communicate and exchange data . Messages - generally XML (Extensible Markup Language) - throughout the Internet.

In other words, Web services are data exchange systems centered on XML that use the Internet for communication and the A2A interface (application to the application). These processes involve programs, messages, documents and / or objects.

An important feature of Web services is that applications can be recorded in several languages ​​and can still be communicated by exchanging data with each other through a Web service between clients and servers. A client invokes a Web service by sending a request through XML and the service responds to an XML response. Web services are also frequently associated with service-oriented architecture (SOA).

To break this, a Web service includes these essential functions:
• Available on the Internet or intranet networks
• Standardized XML messaging system
• Independent of a single operating system or programming language
• Self-description through the standard XML language
• Discovery using a simple location method

A Web service supports communication between several applications with HTML, XML, WSDL, SOAP and other open standards. XML marks the data, the SOAP transfers the message and the WSDL describes the accessibility of the service.

See an example of how it works: a Web service is placed between two sets of Java, .net or PHP applications, providing a way for these applications to communicate over the network. On the one hand, for example, a Java application interacts with java, .net and PHP applications at the other end, through the web service that communicates an independent language.

Web services offer different benefits in business operations. The technology helps IT professionals and Web architects to optimize connectivity, minimizing development time. And with this simplified infrastructure, the executives of the company begin to see a higher ROI (return on investment). In a B2B operation in which both parties understand how the process works, Web services provide efficient distribution of technology throughout the network.

web services

Different Types of Web Services

There are some central types of Web services: XML-RPC, UDDI, SOAP and REST

XML-RPC (Remote Procedure Call) is the most basic XML protocol for exchanging data between a wide variety of devices in a network. It uses HTTP to transfer data and communications quickly and easily to other client information for the server.

UDDI (Universal Description, Discovery, and Integration) is an XML-based standard for detailing, publishing and discovering Web services. It is basically an Internet registry for companies around the world. The objective is to simplify digital transactions and electronic commerce between the company's systems.

SOAP, which will be described in detail later in the blog, is an XML-based Web service protocol for exchanging data and documents over HTTP or SMTP (Simple Mail Transfer Protocol). It allows independent processes that operate in different systems to communicate using XML.

REST, which will also be described in detail at the end of the blog, provides communication and connectivity between devices and the Internet for API-based tasks. Most RESTful services use HTTP as the support protocol.

Here are some well-known Web services that use markup languages:
• Web Model
• JSON-RPC
• JSON-WSP
• WSDL (Web Services Description Language)
• Web Services Conversation Language (WSCL)
• Web Services Flow Language (WSFL)
• Exchange of Web services metadata (WS-MetadataExchange)
• XML interface for network services (XINS)

SOAP Web Services vs. REST

For years, IT professionals and web developers debated which web service is better and why. Well, there is no clear winner - it all depends. Web Services RESTful and SOAP offer different variations. For example, a REST Web service is generally a better option when time is a factor, but the SOAP wins when building a service with several non-CRUD methods. The specific requirements of a company determine the type of web service that a partner will implement, unless it has already been decided by the WS provider.

Then, there are times when both options are the correct answer. This is the case of two of the largest e-commerce companies in the world: Amazon and eBay use Web services for REST and SOAP. And as more organizations focus on services and exploit more features, they will not have the option of not supporting both types.

But what is the difference between REST web services and SOAP web services? We will detail each option as we explore some pros and cons.

RESTful Web Services

What is a RESTful web service? The acronym REST, or sometimes ReST, stands for Representational State Transfer and is an architectural style, which means that each unique URL represents an individual object of some kind. A REST Web service uses HTTP and supports / redirects several HTTP methods: GET, POST, PUT or DELETE. It also offers simple services oriented to CRUD. Curiosity: The original RESTful architecture was designed by one of the main authors of HTTP, Roy Fielding.

Pros: lightweight, readable for humans, easier to build
Cons: Point-to-point communication, lack of standards

SOAP Web Services

SOAP is established in the simple object access protocol. This web service protocol exchanges structured data using XML and generally HTTP and SMTP for transmission. The SOAP also uses WSDL (Web Services Description Language) documents to distribute a web service description model. This describes how SOAP requests (on the client side) and responses (on the server side) should appear. In addition, SOAP web services have security and addressing standards.

Pros: generally easier to consume, more standards (WSDL, etc.), distributed computing
Cons: difficult configuration, more complicated coding, more difficult to develop




Friday, September 28, 2018

Session Tracking Methods


The following answer is applicable, regardless of the language and platform used. To follow things up should be understood before entering the follow-up of the session.

What is a session?

A session is a conversation between the server and a client. A conversation consists of a series of requests and continuous responses.

Why should a session be maintained?

When there are a series of requests and continuous responses from the same client to a server, the server cannot identify which client is receiving requests. Because HTTP is a stateless protocol.
When it is necessary to maintain the conversation state, the session tracking will be necessary. For example, in a shopping cart application, a customer continues to add items to his cart using several requests. When each request is made, the server must identify in which customer cart the item should be added. Therefore, in this scenario, there is a need for session tracking.
The solution is that when a client makes a request, it must be submitted providing a unique identifier each time. There are five different methods to achieve this.

Session tracking methods:


1. User authorization
2. Hidden fields
3. URL rewriting
4. Cookies
5. Session tracking API

The first four methods are traditionally used for session tracking on all server-side technologies. The method of the session tracking API is provided by the underlying technology (Java servlet or PHP or in the same way). The session tracking API is built on the first four methods.

1. User authorization

Users can be authorized to use the web application in different ways. The basic concept is that the user will provide the username and password to access the application. Based on this, the user can be identified and the session can be maintained.

2. Hidden fields

<INPUT TYPE = "hidden" NAME = "technology" VALUE = "servlet" >>
Hidden fields like the previous one can be inserted into the Web pages and the information can be sent to the server for session tracking. These fields are not visible directly to the user, but can be viewed using the browsers' display source option. This type does not need any special configuration of the server's browser and, by default, is available for use in session tracking. This can not be used for session tracking when the conversation included static resources such as html pages.

3. URL Rewriting

Original URL: http: // server: port / servlet / ServletName
Rewritten URL: http: // server: port / servlet / ServletName? Sessionid = 7456
When a request is made, the additional parameter is attached to the URL. In general, the additional parameter added will be sessionid or, sometimes, the userid. It will be enough to track the session. This type of session tracking does not need any special browser support. The disadvantage is that implementing this type of session tracking is tedious. We need to keep control of the parameter as a link in the chain until the conversation is complete and also ensure that the parameter does not collide with other parameters of the application.

4. Cookies

Cookies are the most used technology for session tracking. Cookie is a pair of key value information, sent by the server to the browser. This must be saved by the browser in its space on the client computer. Whenever the browser sends a request to that server, it sends the cookie along with it. Then, the server can identify the customer through the cookie.

In the java, follow the fragment of the source code to create a cookie:
Cookie cookie = new Cookie ("userID", "7456");
res.addCookie (cookie);
Session tracking is easy to implement and maintain using cookies. The disadvantage is that users can choose to disable cookies using their browser preferences. In this case, the browser will not save the cookie on the client computer and the session tracking will fail.

5. Session tracking API

The session tracking API is built on the first four methods. This is in order to help the developer minimize the overhead of session tracking. This type of session tracking is provided by the underlying technology. Let's take the example of the Java servlet. Next, the servlet container manages the session control task and the user does not have to do it explicitly using the java servlets. This is the best of all methods, because all the administration and errors related to the session tracking will be handled by the container itself.

Each server client will be assigned with a javax.servlet.http.HttpSession object. Java servlets can use the session object to store and retrieve Java objects in the session. Session tracking is best when it is implemented through the session tracking API.










Thursday, September 27, 2018

Internet cookies


COOKIES


Everyone has heard about cookies, but many companies may not be fully aware of what they are and if they are useful. Here, we introduce cookies, their types and uses and the control that companies can have over them.

What are cookies?

A cookie is a small text file embedded in your hard drive by the server of the site you are visiting. This file is neither a virus nor spyware.
What are they used for?

Cookies are used to facilitate web browsing. What really happens when you visit an online store for the first time is that the site server sends a file to your computer, which is automatically installed on the disk. Thanks to this cookie, you will be recognized the next time you visit the same site and you will not have to insert all your details again. In a few words, cookies personalize your web experience.

Advantages and disadvantages of cookies

There are several types of cookies - the ones we love and the ones we hate!

We love those who facilitate our lives because they simplify surfing and let us be recognized more quickly in different places.

We hate those who are used primarily for sales or marketing purposes. In fact, some cookies analyze our purchasing behavior and / or navigation, and the resulting data can be analyzed and used as a marketing tool, which some customers may find intrusive.

Types of cookies

There are three different types of cookies:

• Session Cookies: are used mainly by online stores and allow you to store items in your basket when making purchases online. These cookies expire when the browser is closed

• Permanent cookies: these remain in operation, even when you have closed the browser. They remember your login details and password, so you do not have to write each time you use the site. The law regarding permanent cookies stipulates that these must be deleted after a period of six months

• Third party cookies: they are installed by third parties with the aim of collecting certain information to carry out various investigations on behavior, demographics, etc.

Can cookies be erased or blocked?

You will be invaded by Internet cookies, regardless of the browser you use (Internet Explorer, Chrome, Mozilla, etc.). Although there are no miracle solutions, you can consider the following:

Delete cookies: all you need to do is find the folder / file where cookies are stored on your computer and delete them. If you do it manually, you must remember that you do it regularly.

Block cookies: if you want to block the site's cookies, you must configure your browser to categorically reject all cookies that try to access your computer. The only disadvantage of this option is that it will no longer be automatically recognized in your online favorite. You need to be careful, because categorically blocking certain cookies may mean that you can no longer buy online

• Define the alert system of your browser: simply configure your browser to notify you each time a cookie is sent, allowing you to decide whether or not to allow the cookie. The only disadvantage of this solution is that you will spend more time rejecting or accepting cookies than browsing the web.

• Use specialized software: you can download software that protects you against cookies. These software programs can be configured to allow you to change the content of the cookies that apply to you. These programs, some of which are free, can be downloaded on the Internet.









Wednesday, September 26, 2018

Introduction to the AWT

Introduction

The Java programming language class library provides a user interface toolkit called Abstract Windowing Toolkit or AWT. AWT is powerful and flexible. Newcomers, however, often find their power veiled. Descriptions of classes and methods found in distributed documentation provide little guidance to the new programmer. In addition, the available examples often leave many important questions unanswered. Of course, newcomers should expect some difficulty. Effective graphical user interfaces are inherently challenging to design and implement, and the sometimes complicated interactions between classes in AWT only make this task more complex. However, with proper guidance, creating a graphical user interface using AWT is not only possible but relatively simple.


This article discusses some of the philosophies behind AWT and addresses the practical concern of how to create a simple user interface for an applet or application

What is a user interface


The user interface is the part of a program that interacts with the user of the program. User interfaces take several forms. These forms vary in complexity, from simple command-line interfaces to the point-and-click graphical user interfaces provided by many modern applications.


At the lowest level, the operating system transmits mouse and keyboard information to the program as input and provides pixels for program output. The AWT is designed so that programmers do not worry about the details of tracking the mouse or reading the keyboard, or attending to the details of recording on the screen. AWT provides a well-designed object-oriented interface for these services and low-level resources.


Since the Java programming language is independent of the platform, the AWT must also be independent of the platform. The AWT is designed to provide a common set of graphical user interface design tools that work across multiple platforms. The user interface elements provided by AWT are implemented using the native GUI toolkit of each platform, thus preserving the appearance of each platform. This is one of the strongest points of AWT. The disadvantage of this approach is the fact that a graphical user interface designed on one platform may look different when it is displayed on another platform.


Components and containers


A graphical user interface is constructed of graphic elements called components. Typical components include elements such as buttons, scroll bars, and text fields. The components allow the user to interact with the program and provide the user with visual feedback on the status of the program. In the AWT, all the components of the user interface are instances of the Component class or one of its subtypes.


The components are not alone, but they are in containers. The containers contain and control the design of the components. The containers are themselves components and, therefore, can be placed inside other containers. In the AWT, all containers are instances of the Container class or one of its subtypes.


Creating a container


Before adding the components that make up a user interface, the programmer must create a container. When building an application, the programmer must first create an instance of the Window class or the Frame class. When creating an applet, a framework already exists (the browser window). Since the Applet class is a subtype of the Panel class, the programmer can add the components to the instance of the Applet class itself.




Tuesday, September 25, 2018

Introduction to hibernate framework


Before understanding the hibernation framework, we need to understand the Object Relational Mapping (ORM).

What is ORM?

ORM is a programming method to assign objects in java with the relational entities in the database. In this, entities / classes refer to the table in the database, the class instance refers to the rows and attributes of class instances refers to the table column in the database This provides solutions to problems that arise during the process of developing persistence applications using the traditional JDBC method. This also reduces the code that needs to be saved.

Need for tools like hibernate:

The main advantage of ORM like hibernate is that it shields developers from messy SQL. Apart from this, ORM provides following benefits:

Improved productivity:

§  High-level object-oriented API
§  Less Java code to write
§  No SQL to write
Improved performance:

§  Sophisticated caching
§  Lazy loading
§  Eager loading
Improved maintainability:

§  A lot less code to write

Improved portability:

§  ORM framework generates database-specific SQL for you

What is hibernate?

Hibernate is a relational object mapping (ORM) and a persistence structure that allows you to assign simple old Java objects to relational database tables. The main objective of hibernate is to free the developer from common tasks related to data persistence. the objects in the java with the tables in the database very efficiently and also you can get the most out of using your facilities of consultation and data recovery. Mainly using Hibernate in your projects, you can save incredible time and effort.

Architecture of hibernate :

Following is a detailed view of the Hibernate Application Architecture with few important core classes.



The Hibernate architecture is placed in layers to keep it isolated from having to know the underlying APIs. Hibernate is like a bridge between the Java application and the relational database.

Session interface:

This is the main interface used by hibernation applications. Instances of this interface are slight and are not expensive to create and destroy. Hibernation sessions are not secure threads. It allows you to create query objects to retrieve persistent objects. It refers to the JDBC Factory for Transaction connection. It contains a mandatory cache (first level) of persistent objects, which is used when navigating the object graphic or searching for objects by identifier.

Session session=SessionFactory.openConnection();

SessionFactory Interface:

This is a factory that delivers session objects to hibernate the application. It is a heavy object, so there will usually be a single SessionFactory for the entire application and it is shared among all sub-processes of the application. SessionFactory caches generate SQL statements and other metadata mapping that Hibernate uses at runtime. It also stores cached data that has been read in a unit of work and can be reused in a future unit of work.

  Configuration configuration=new Configuration();
  configuration.configure();
  ServiceRegistry sr= new ServiceRegistryBuilder().applySettings(configuration.ge    tProperties()).buildServiceRegistry();
  SessionFactory sf=configuration.buildSessionFactory(sr);

SessionFactory object is created with the help of configuration object.

Configuration Interface :

This is used to configure hibernate. It’s also used to bootstrap hibernate. Mapping documents of hibernate are located using this interface.

Transaction Interface :

This is an optional interface but the above three interfaces are mandatory in each and every application. This interface abstracts the code from any kind of transaction implementations such as JDBC transaction, JTA transaction.

Query and Criteria Interface :

This interface allows the user to perform queries and also control the flow of the query execution.



From Java 8 to Java 11

Switching from Java 8 to Java 11 is more complicated than most updates. Here are some of my notes on the process. Modules Java 9 i...