Friday 13 April 2018

SOAP vs REST web services or Difference between SOAP and REST web services

Before we start differentiate between SOAP vs ReST web services let’s understand what is web service?
According to web definition from WIKI –
“…A web service is a method of communication between two electronic devices over World Wide Web. It is a software function provided at a network address over the web with the service always on as in the concept of utility computing.
In simple words – Web service is a mechanism that provides data as a service/response over the http protocol on request of some other programs.

What is the difference between web site and web service?

Most of the people don’t know the difference between web service and web site. The two looks similar but Web service is different than Web Site.
Web Site is something that presents data on a browser in human readable format. The web sites are meant for easy user navigation. These are basically HTML pages in human readable format when rendered on browser.
Web Service offers service to some other software applications. Upon receiving a request from these software applications it produces a response. This request can also contain some input data for the service to process and depending upon the input data it returns a result.
The result provided by web services are usually meant for software’s so that they can consume it, process it and optionally present well formatted data on the web site. The result produces by web services may or may not be easily readable by the humans. They are meant for software applications only. The popular result formats are XML and JASON. These popular formats are easy to parse and use.
A website may or may not use webservice.
Example of Website: You can go to website https://www.google.co.in/maps and use it to search a map for your address.
Example of Webservice: You have built your own website and on that website you want to show the address of your site visitor. In this case you can call a webservice provided by google maps, pass the desired address to this web service and it will return a map. And now you can show this map on your website.
I hope now you get the clear idea about what is web service and web site. Now let’s take a look at two different types of web services i.e. SOAP and ReST.
ReST and SOAP are the set of specification of information to be used in the implementation of web services. These are messaging protocols used to exchange the information between two programs. The exchange of information is one-way.

What are soap services? / What is soap service?

Simple Object Access Protocol (SOAP) is a XML based structured protocol specification to be used in the implementation of web service. In simple words SOAP web services uses XML as a mechanism for exchanging of information (one way) between the two programs (end points) over any transport layer protocol.
Though for message negotiation and transmission soap is not relies on any particular transport protocol but HTTP (Hyper Text Transfer Protocol) or SMTP (Simple Mail Transfer Protocol) are the two most popular transport protocols used with SOAP. Similarly SOAP is not relying on any particular programming language or operating system as far as they understand XML and SOAP message.
For example, one program running in Windows operating system such as Windows 7 can communicate to another program running in Linux operating system. For this soap will use XML and HTTP.
SOAP message is consist of three parts, i.e. envelope, header and body as shown in below image.
Simple SOAP Architecture
Simple SOAP Architecture

SOAP:envelope

The root element of SOAP message is a SOAP envelope which states what is in the soap message and how to process it. Application looks at the soap:envelope and easily determines what could be the SOAP message. It also helps application to identify the version of the SOAP being used.

SOAP:header

SOAP:Header is an optional element of the soap message. The element from this part contains application specific information. The information should be related to soap message and could be anything like authentication method or payment methods etc.
Though it is an optional element, but if present then it should be the first child element of the soap:envelope.

SOAP:body

SOAP:body is a mandatory element unlike soap header. This part contains all information related to call and response of the web service. Actual soap message goes here.
The format of soap message is as below –

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<!-- Header elements. -->
</soap:Header>
<soap:Body>
<!-- Body elements. -->
</soap:Body>
</soap:Envelope>
The most important aspect of the SOAP is that without making any changes to the original SOAP message it can tunnel through firewalls and proxies.

What are restful services? / What is restful service?

REST stands for REpresentational State Transfer is a newcomer in its type of family. REST provides very easy access and implementation to a web service that ultimately aims to work best on the web. Restful web services are an architecture style stateless web services mostly used for building client-server applications over HTTP.
In REST, every resource is addressed or accessed by Unique URI (Uniform Resource Identifier) and data and functionality forms a resource. Representation State Transfer defines some set of operations and resources acts according to these operations.
Instead of using XML for request/response, it relies on simple unique URI and that’s why it is also considered as lightweight alternative to SOAP. As it is rely on URI as a resource identifier, the standard CRUD operations of HTTP (GET, PUT, DELETE, POST, HEAD) can be performed on that URI/resource.
SOAP provides the response in XML format only while REST doesn’t have to use XML only. Though XML and HTML formats are often used for REST response, REST can also response in JASON, CSV and RSS formats. There are various options you can choose for the parsing of the REST response. Each of these responses has their own advantages and disadvantages.
“ReST” is lightweight service alternative to most of the mechanism including SAOP and RPC (Remote Procedure Call) but it has no “W3C” recommendations.
In short, ReST is simple, language & platform independent and Standard HTTP based mechanism that can be used through the Firewalls also.
Following are few simple examples of Get & POST upon ReST –
Example 1 :
  1. Request: (URL – http://abc.com/)
    GET /
    Accept: application/json+userdb
  2. Response :
    200 OK
    Content-Type: application/json+userdb
    {
    "version": "1.0",
    "links": [
    {
    "href": "/category",
    "rel": "list",
    "method": "GET"
    },
    {
    "href": "/category",
    "rel": "create",
    "method": "POST"
    }
    ]
    }
Example 2 :
  1. Request : (URL – http://abc.com/category)
    GET /category
    Accept: application/json+userdb
  2. Response :
    200 OK
    Content-Type: application/json+userdb
    {
    "categories": [
    {
    "categoryid": 1,
    "categoryname": "Mobile",
    "links": [
    {
    "href": "/category/1","rel": "self","method": "GET"
    },
    {
    "href": "/category/1",
    "rel": "edit",
    "method": "PUT"
    },
    {
    "href": "/category/1",
    "rel": "delete",
    "method": "DELETE"
    }
    ]
    },
    {
    "categoryid": 2,
    "categoryname": "Tablet",
    "links": [
    {
    "href": "/category/2",
    "rel": "self",
    "method": "GET"
    },
    {
    "href": "/category/2",
    "rel": "edit",
    "method": "PUT"
    },
    {
    "href": "/category/2",
    "rel": "delete",
    "method": "DELETE"
    }
    ]
    }
    ],
    "links": [
    {
    "href": "/category",
    "rel": "create",
    "method": "POST"
    }
    ]
    }
Example 3:
  1. Request : (URL – http://abc.com/category)
    POST /category
    Accept: application/json+userdb
    Content-Type: application/json+userdb
    {
    "categoryname": "Laptops"
    }
  2. Response :
    201 Created
    Content-Type: application/json+userdb
    {
    "category": {
    "categoryid": 3,
    "categoryname": "Laptops",
    "links": [
    {
    "href": "/category/3",
    "rel": "self",
    "method": "GET"
    },
    {
    "href": "/category/3",
    "rel": "edit",
    "method": "PUT"
    },
    {
    "href": "/category/3",
    "rel": "delete",
    "method": "DELETE"
    }
    ]
    },
    "links": {
    "href": "/category",
    "rel": "list",
    "method": "GET"
    }
    }
  3. http://www.csharptutorial.in/296/wcf-tutorials-soap-vs-rest-web-services-or-difference-between-soap-and-rest-web-services

Monday 9 April 2018

Major differences between Angular 1 vs Angular 2 vs Angular 4

In last five years, AngularJS has been evolved tremendously. It has advanced from AngularJS version 1.0 to Angular version 2.0 and now Angular version 4.0. The AngularJS Development Company makes use of the features provided by the Angular 1.0 to 4.0 which brought major improvements of the developed code size. It provides great impact on application performance and security. The migration has been quite smooth for the AngularJS developers.
Architecture
Version 1.0 vs. Version 2.0 
Angular 2.0 shows a substantial change in the structure as compared to version 1.0. The architecture of Angular v1 is based on MVC whereas the architecture of Angular v2 is based on service/controller. There is very less possibility to upgrade the Angular v1 to v2, mainly developers have to rewrite the entire application code. 
Version 2.0 vs. Version 4.0 
The upgrade of the version from 2.0 to 4.0 has reduced it’s bundled file size by 60%. The code generated is reduced and has accelerated the application development. Here the developed code can be used for prod mode and debug.  
JavaScript and TypeScript 
v 1.0 vs. v 2.0  
Angular v1.0 use JavaScript to build the application while Angular v2.0 uses the Typescript to write the application. TypeScript is a superset of JavaScript which helps to build more robust and structured code. Dart can be used by developers along with TypeScript in version 2.0. 
v 2.0 vs. v 4.0 
Angular v4.0 is compatible with newer versions TypeScript 2.1 and TypeScript 2.2. This helps with better type checking and also enhanced IDE features for Visual Studio Code.  
Mobile Support
Angular 2.0 has made it possible to accomplish the native applications for a mobile platform like React Native. Angular 2.0 gives us the two layers: application layer and the rendering layer. As need, any view can be rendered in runtime for the required component. 
Component-based UI 
1.0 vs. 2.0 
The controller concept which was present in Angular v1.0 is eliminated in Angular v2.0. Angular v2.0 has changed to component based UI. This helps a developer to divide the applications in terms of components with desired features and enable to call required UI. These have helped to improve the flexibility and reusability as compared to Angular v1.0 
SEO Friendly
1.0 vs. 2.0
With Angular v1.0 developing the search engine friendly Single Page Applications was the major difficulty. But this bottleneck was eliminated in Angular v2.0. AngularJS development services build SEO friendly Single Page Applications by rendering the HTML at the server side.
2.0 vs. 4.0
Features of Angular version 4.0 
• View engine with less code 
The view engine is introduced in Angular 4 where the produced code of components can be reduced up to 60%. The bundles are reduced to thousands of KBs.       
  • Router ParamMap 
Before Angular 4, simple object structures used to store route parameters. 
These Parameters were assessed by simple standard JavaScript syntax.
Syntax 
(parameterObject[‘parameter-name’] )
But now in Angular 4, these parameters are available as a map. To use these parameters simple methods are called. 
Method call 
(parameterMap.get(‘parameter-name’))
This adds to the type security. Old values were unsafe in regards to the type as these values could take any type possible. But now, these values are string or array of strings.
Animation Package
Up till AngularJS the code required for the animation part was always included in the application in spite of the fact that animation is actually used or not. The functions required for the same were also provided as a part of @angular/core module. 


But now in Angular 4, the animation is part of a separate package. This has eliminated the unnecessary bundles with large sized files.


Animation can also be avail from module BrowserAnimationsModule from @angular/platform-browser/animations. 
• ngIf with a new else statement 
Information which is dependent of one another is displayed with the help of “conditional rendering”. If any condition is not met, then resultant element and all child elements are not added to the DOM-tree.


Commonly there was additionally a requirement for a contrasting case, making it important to figure a similar condition a different way using another *ngIf. We were required to use if statement all the time. While dealing with big and multiple lines of codes it was very difficult to maintain and go through these awful implications. But with Angular 4 this was solved with the help of ‘else’. 
• Smaller and faster
Angular 4 has made the code file size smaller and improved the speed of the application check the features of Angular 4 in detail.
• Pipes
The first letter of each work is changed to Uppercase with the use of Pipe. Pile is a new title case introduced in Angular 4. It takes first letter o word to uppercase and remaining is kept in a small case. 


• Template
In Angular 4, the <ng-template> tag ought to be utilized rather than the <template> tag as it has been expostulated and set apart as inadmissible. Likewise, it's presently conceivable to utilize else syntax in the template. It will pop warning on the off chance that you utilize the deprecated layout someplace when you are at Angular 4, so it will be anything but difficult to spot them. It's a breaking change; with the semantic versioning rules, this has been incorporated in Angular 4. 


  •  Better and efficient debugging with the use of source maps.
  • Enable to develop powerful Single Page Application (SPA) which is 100% SEO friendly.
• Http:
Adding search parameters to an HTTP request has been simplified. 


Future Prospect 
The major release is specified by the team after a certain interval of time: 
• The bug fixes and patches will be applied every week.
• Minor releases will be done every month.
• Major releases with the migration from the prior version to new updated one will take place after every 6 months.

Why skipped Angular 3
angular packages

The angular team already updated @angular/router with version 3.X before Angular 3 would have been released that's because of major development on router packages, like router-preload. So to avoid such confusion between Angular package with angular version. They decided to skip the Angular version 3 and directly released angular 4. so that dependency in the MonoRepo will be right on track.
Conclusion 
The application development using AngularJS provides with more secure, flexible and scalable pathway. It is a very simple and easy task to upgrade Angular 2.0 to 4.0, but this has to be done only if the applications demand it. 
There is need to check the challenges and bottleneck faced while updating the applications in Angular v4.0 which was built in Angular 2.0.

Recent Post

Parallel Task in .Net 4.0