Thursday, August 15, 2019

Web Services vs API for Rookies

                                             Web Services vs API for Rookies

Hi Guys, I am so sorry for writing back after a long gap! I was occupied with so many things and I got sailed away from writing. I am back now...

I have got deluge of emails and requests,so I am writing again. I have observed that many of the HR professionals and people with zero knowledge on technical area are getting into Workday and a lot of freshers are showing interest to get into Workday jobs. 
Most of them are  in two minds and come with queries whether they have to write programs or mandatory to have technical experience on programming side ?  

I suggest that to have knowledge is always good as you can understand the flow and the functionality easily.
You will tend to  hear about web services in WORKDAY STUDIO, so I am writing the difference between web services and API for better understanding. 

As you know that functional area doesn't require much knowledge on the technical aspects but when it comes to the integration and Workday Studio, I feel its better to have an idea on the API and Web services ( SOAP, REST)

I have already covered XML area in my blog. 

I am writing this for peers who doesn't have any technical background. I hope this workday blog helps them. 


                                               Web Service vs API :
WEB SERVICE:
A Web service is designed to have an interface that is depicted in a machine-processable format usually specified in Web Service Description Language (WSDL). Typically, “HTTP” is the most commonly used protocol for communication. Web service also uses SOAP, REST, and XML-RPC as a means of communication. 

It's a service available over the web. In a simple way to understand, here goes an example. 
Lets take the restaurant scenario: A french customer visits an Indian restaurant and wants to order some traditional Indian food. The Hotel staff should be in a position to understand the french language to take the order and serve the customer their signature Indian dish. 
At this point, the waiter who understands the language will be taking the order from the customer and translates the same to the kitchen department to cook.
In this scenario, the 'waiter' acts as a WEB SERVICE and customer and kitchen as TWO DIFFERENT LANGUAGE applications. 

A Web service is merely an API wrapped in HTTP. An API doesn’t always need to be web based. An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction. A Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API.
The APIs can be exposed in a number of ways which include: COM objects, DLL and .H files in C/C++ programming language, JAR files or RMI in Java, XML over HTTP, JSON over HTTP, etc. The method used by Web service to expose the API is strictly through a network.

Medium: HTTP/Internet
Format:XML/JSON

There are two types of web services -SOAP and REST

SOAP(Simple Object Access Protocol)- A web service that compiles to the SOAP web services specifications is a SOAP web service
Medium: HTTP ( POST)
Format: XML

W3C(world wide web consortium) defines the standards.
There are two SOAP web services specifications
1) Basic 2) Extended
* SOAP
* WSDL
* UDDI  

All the information that happens between service consumer(CLIENT) and service provider(SERVER) is over a common format XML. XML message has a defined structure : SOAP MESSAGE consists of 
* Envelope
* Header
* Body

Here is the SOAP XML structure:-

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encoding Style="http://www.w3.org/2003/05/soap-encoding">

<soap:Header>
...
</soap:Header>

<soap:Body>
...
  <soap:Fault>
  ...
  </soap:Fault>
</soap:Body>

</soap:Envelope>

Envelope: It is the root element of a SOAP message. This is basic unit of the XML document which contains other units like Header and body. 

Header: A element provide the information about the message itself. Header might include complex types, routing information etc.

Body: It contains actual data of the request that is meant to be sent to the server. 




REST: REpresentational State Transfer----- It is more flexible and less rigid than SOAP

Medium:HTTP (POST, GET,PUT,DELETE,...)
Format: XML/JSON/TEXT

REST is often misunderstood in web service. A web service that communicates/exchange information between 2 applications using REST architecture is called as Restful web service . It is an architectural style . It doesn't have any protocol or strict specifications unlike SOAP and there is no central body controlling.

REST defines a set of principals to be followed while designing a service for communication/data exchange between 2 applications. When these principles are applied while designing web services ( client-server interactions) we get RESTful web service.

The principals of REST Architecture that should follow to become a restful web service 
* Uniform Interface
* stateless 
* cacheable etc... 

Resource: Everything is a resource 
URI: any resource/data is accessed by a URI 
HTTP: make explicit use of HTTP methods

1) Resource: everything is a resource ...

Example- We are creating Human Resource tracking system ( HRTS). We can create this system on any platform and on any language and on any database at the back end. 
To develop HRTS, we should have some modules like employees which will have attributes like 'employee name' and 'employee ID' and then Department module like 'Department name' and 'Department ID' and other modules.
The concept of resource says that we can define any information on any module as resource.
We can define resource as 'employee' 'department'... every module we can name as resource.

2) URI: we can access resource/data through URI ( uniform resource identifier)
If the HRTS software is developed and hosted somewhere and we can access it by using the domain name/ employees to get the employees data
http://hrts.com/employees ( we get all employees data).
If we want employee 26 details then we can access http://hrts.com/employees/26

3) HTTP: let us see how we make use of HTTP methods:
HTTP -  GET, POST, PUT, DELETE are few methods. We can CREATE using POST
READ using GET, UPDATE using PUT and DELETE using DELETE----- CRUD ( SHORT FORM)

using HTTP methods along with URI, we can access/modify any resource or resource information.


                REQUEST                    RESPONSE 

GET- http://hrts.com/employees list of employees
GET- http://hrts.com/employees/26 lists details of employee with ID 26
DELETE- http://hrts.com/employees/26 deletes the details of employee with ID 26
POST- http://hrts.com/employees ID of new employee
+
  Data of new employee

PUT- http://hrts.com/employees/26 modify data of employee 26
+
data to be changed

http:// GET hrts.com/employees/26


Difference between SOAP and REST web service to get the details of the employee having ID 26


                                            SOAP
========================================================================

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encoding Style="http://www.w3.org/2003/05/soap-encoding">

<soap:Body pb="http://hrts.com/employees">
  <pb:GetEmployee>
<pb:Empid>26</pb:Empid>
</pb:GetEmployee>
</soap:Body>

</soap:Envelope>

=============================================================================


                                REST

http://hrts.com/employees/26

In Rest we will not be writing the complete coding rather we go with simple link 
 ============================================================================


                         COMPONENTS OF WEB SERVICES: 1) WSDL 2) UDDI

WSDL- Web service description language
Service provider publishes an interface for his web services that describes all attributes of the web services. This is XML based interface called WSDL.

CLIENT (service consumer) - SERVER(service provider)

There are two ways a service consumer can get hold of this WSDL document
1) If the service consumer and the service provider already know each other. The service provider can hand over the WSDL to the client and they can use the service.
2) When the service provider and the service consumer doesn't know each other... how can service consumer can get hold of WSDL document?
Ans: A web service provider publishes his web service (through WSDL) on an online directory from where consumers can query and search the web services. This online registry/directory is called UDDI ( Universal Description, Discovery and Integration)- It is an XML based standard for publishing and to find web services. It is like UDDI is a directory where the service provider will put WSDL documents where consumer can query and get hold of their choice WSDL document.

************************************************************************************************************                                              
API ( Application Programming Interface) and Web service serve as a means of communication.
The only difference is that a Web service facilitates interaction between two machines over a network. 
An API acts as an interface between two different applications so that they can communicate with each other.
An API is a method by which the third-party vendors can write programs that interface easily with other programs.
API may use any means of communication to initiate interaction between applications. For example, the system calls are invoked using interrupts by the Linux kernel API.
An API exactly defines the methods for one software program to interact with the other. When this action involves sending data over a network, Web services come into the picture. An API generally involves calling functions from within a software program.
In case of Web applications, the API used is web based. Desktop applications such as spreadsheets and word documents use VBA and COM-based APIs which don’t involve Web service. A server application such as Joomla may use a PHP-based API present within the server which doesn’t require Web service.

An API is nothing but the flexibility between two applications to talk to each other irrespective of the different program.
Ex: Google map API, YouTube API


Summary:
1. All Web services are APIs but all APIs are not Web services.
2. Web services might not perform all the operations that an API would perform.
3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for
communication whereas API may use any style for communication.
4. A Web service always needs a network for its operation whereas an API doesn’t need
a network for its operation.
5. An API facilitates interfacing directly with an application whereas a Web service is a


                                    If you have any queries, do not hesitate to write to me.

Thursday, December 31, 2015

XML- LOOK

Hope all of you had rocked 2015!  Last day of the year, many might be getting ready to party hard and few with resolutions to make it big in their careers.  All the best and make the most of it.

                                                                   XML: LOOK

<?xml version="1.0"? >  Declaration
<!.. My first XML document.. > comment

<message status="urgent" type="friendly">
 start tag  ...attribute...
<text>Hello Joy</text>
<subject>How are you</subject>
</message>

The above document contains start tag, attribute, sub-elements,declaration and comments.


Root is the outmost element in the above case <message> 
Elements can contain child elements ( e.g., message contains text and subject)

Attribute-( message status="urgent" type="friendly"
Name-value pair separated by "=" sign... similar to attributes in the HTML tags.
Attributes of elements are defined in the starting tag not at the end tag.

XML has become useful in three major areas
1) Putting data on the web
2) Storing/Sending system data
3) Exchanging data between applications.

Data described using markup language
Each individual piece of information is "marked up" A marker shows the meaning of the associated data- <name>Joy</name>
        Start tag-content-End tag

A unit of data to which a meaning has been attached is called an "element". An element consists of 'Start tag', 'content','End tag'.

When required an "attribute" can be described in the start tag of an element showing more detailed information to be assigned to the data.
<name id="26">Joy Joshi</name>
            .attribute.

Mark: Tag names are case-sensitive.They come in two flavours 
1) Paired - <title>Joy to the world</title>

2) Empty: A single tag with no closing tag- Elements require no data
Data can be provided through tag attributes
Ex:  <customer number="CUST123" name="Joy"/>
                                                                                 Empty tag
Attribute value are always quoted strings...passing application must convert to other data types.
Can begin with and contain any characters except (Digits, whitespace,punctuation etc.,)

Example using tag attributes:

<customer number="CUST123" 
status="VIP"
account manager="EMP007"
<name>Joy</name>
</customer>


Customer has three attributes
1) Number
2) Status
3) Account Manager

                                                              COMMENTS

XML uses comments like other languages.

Notes to a human being-Not interpreted by parsers.

                                           <!.. comment.. >

Rule for using comments
1) No comments before XML declaration in the first line
2) No comments within other markups
3) Don't use "--" ( two hyphens) within comment text.
4) No nested comments.













Saturday, December 5, 2015

WORKDAY: XML+Xpath+XSL



                                                     XML+Xpath+XSL

I am sorry for taking a long break in writing up. I was held with work, so didn’t get the time... as well excuse me for not replying to the ‘flood of emails’ received from you guys asking suggestions and assistance. I will reply soon once I sort out my inbox.

In WORKDAY integration plays an important role for the successful run of the projects.

WORKDAY always interacts in XML format.

Most of the cloud applications talk in XML and WORKDAY generates automatically XML file.
We use XML with the assistance of web services; they are the building blocks for construction of applications.
                                        Extensive Mark up Language-XML

XML is a data language based on text markup (special markers (tags) in the text that identify its parts).
Markup Language: Set of rules for marking up a text. A markup language defines what tags you may use how and where to use them.
HTML is a markup language-The key difference between HTML & XML is…
HTML is designed for display and uses ‘CSS’ for manipulating display.
HTML data is fixed and mostly about presentation.
-----------------------------------------------------------------------------------------------------------------
XML: It is designed for data and uses ‘XSLT’ for manipulating data & display for multiple output types.

·      Basic XML provides a ‘grammar’ for markup.
·      Elements must conform to certain rules making XML a meta-markup language.
·      Human and computer friendly format.
·      Excellent for long term data storage and data reusability.
·      Handles the data in a tree structure having one and only one root element.

XML gives an excellent service for handling data with a complex structure.

·       Data managed using RDB tables has a regular data structure.
·     In today’s fast changing world, most of the data that exists is not structured and at times cannot be managed using tables like… Complex Structure and Atypical data.

There are many applications & tools in the market competing to streamline the data and one such format that can handle data without an extensive manipulation is ‘XML’.
XML allows for the description of data in a text format as it uses the text data, whereas, data delivered back & forth without OS obligation.
XML data can be stored for long periods without the fear of thinking unusable, whereas, data created through specific application becomes useless or even impossible to access if the application is unusable.

Using XSLT, an XML document can be transformed into a document of a different structure or format (HTML,CSV,etc)  ONE SOURCE-MULTI USE solution.
XSLT style sheet is designed to use single XML document for various purposes (the web or mobile phones)