Advertisement

Responsive Advertisement

REST services webMethods

Representational State Transfer (REST) is an architectural style used to build distributed hypermedia systems. The World Wide Web is the best known example of such a system.

The focus of REST is on resources rather than services. Resources are the entities or collections of entities in a distributed system that you want to post or retrieve or take action on. In a REST style system, each resource is identified by a universal resource identifier (URI).

RESTful web services are light weight, highly scalable and maintainable and are very commonly used to create APIs for web based applications.

History of REST Services :
  • Roy Fielding first talked about the REST concept in 2000.
  • As stated earlier REST stands for representational state transfer.
  • REST styled architecture is also called as WOA .
  • REST introduced a concept of resources . Client initiate the communication with Server , to get details about resources or modify the resources in some way or other.
  • REST web services can use any underlying protocol , but most commonly used protocol to created rest web services is HTTP .
How REST Communication works ?

As in all the client-server communication , the request is initiated by the client.
  • The client calls the respective REST service passing the correct URI and correct http methods.
  • The clients gets the response (result document) from the server.
  • In a RESTFul web service , the http methods GET , POST , PUT and DELETE are already defined and associated with CRUD operations.


HTTP Methods and CRUD Analogy :

Note : Not all methods are supported by all rest resources.

Advantages of REST Services :
  • Based on System resources.
  • Simple to use.
  • Uses HTTP methods.
  • Is Stateless
  • Expose directory structure as URIs
  • Transfer XML , JSON ,Javascript etc.
While designing REST services please consider the following points :
The system resource should be self-documenting , requiring little explanation



  • straight forward 



  • predicatable 



  • easily understood (directory structure result format should be known to client)

  • REST Services in Integration Server
    • REST Provider
    Integration server acts as a REST provider , i.e we can create REST services in Integration server and expose it.
    • IS supports all four http methods i.e get , post , put , delete . 
    • You can also create a default service which will be invoked when there is no corresponding service for a http method.
    • Routing of URL and HTTP method to IS service
    • Service input include values from the URL path and http method
    • Calling REST services created on Integration server , the URL to be followed is mentioned below :
      • http://host:port/REST_Directive/Resource
      • The restDirective is simply called rest. So, the URL will be for e.g. http://myhost:5555/rest/restexample/library/books
    • Integration Server REST processing :
      • IS parses the http tokens and identifies the appropriate service to be called based on the http methods
      • Locates the resource to act upon. On IS the folders present inside a package act as a resouce.
      • Each rest resource has individual services for  http methods.
      • IS rest service can accept additional parameters as well
    Steps to Create REST provider resource in the Integration Server :
    • Right Click on Designer and select REST Resource

    • Provide the REST resource name and click on next
    • Select all the HTTP methods which you want for this resource , you can also select default if any of the HTTP method is not selected.
    • This will create all the respective HTTP methods wrapper flow services.


    Note : You can add additional input parameters to the REST services created.

    • REST Consumer
    Integration server has the capability to consume REST services.
    • You can make use of pub.client:http to consume web services. This service has all the required capabilities.
    • Select the method
    • Pass on the parameters
    • And you are ready to call the rest service.
    Refer the below screenshot on how to call the REST service .



    You can use args input Document Optional. Name/value pairs that you want this service to submit to the resource in url . You can use args to submit data via the POST, PUT, GET, or HEAD method.
    To specify data using args , create one String element for each name/value pair that you
    want to submit, where the element's name represents the name portion of the pair and the
    element's value represents the value portion of the pair.

    When you use args , the http service will automatically:
    • sets the value of the Content-Type header to application/x-wwwform-urlencoded.
    • URL encode the inputs
    • Separates the entries with "&"
    • Prefix the entire query string with the "?"



    Enjoy Reading , If you have any Question related to webMethods please comment below , I will try to answer the questions.Please Subscribe for latest update on the blogs

    Post a Comment

    4 Comments

    1. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingmulesoft online training

      ReplyDelete