19 February 2014

Service Oriented Architecture -Architectures

          Service Oriented Architecture is based on the concept of a service. Depending on the taken service design approach, each SOA service is designed to perform one or more activities by implementing one or more service operations. As a result, each service is built as a discrete piece of code. This makes it possible to reuse the code in different ways throughout the application by changing only the way an individual service interoperates with other services that make up the application, versus making code changes to the service itself. SOA design principles are used during software development and integration.
        It generally provides a way for consumers of services, such as web-based applications, to be aware of available SOA-based services. For example, several disparate departments within a company may develop and deploy SOA services in different implementation languages; their respective clients will benefit from a well-defined interface to access them.


        It defines how to integrate widely disparate applications for a Web-based environment and uses multiple implementation platforms. Rather than defining an API, SOA defines the interface in terms of protocols and functionality. An endpoint is the entry point for such a SOA implementation.

      Service-orientation requires loose coupling of services with operating systems and other technologies that underlie applications. SOA separates functions into distinct units, or services which developers make accessible over a network in order to allow users to combine and reuse them in the production of applications. These services and their corresponding consumers communicate with each other by passing data in a well-defined, shared format, or by coordinating an activity between two or more services

      The main benefit of SOA is to allow simultaneous use and easy mutual data exchange between programs of different vendors without additional programming or making changes to the services. These services are also reusable, resulting in lower development and maintenance costs and providing more value once the service is developed and tested

 Principles of Service Oriented Architecture:
  •          Standardized service contract: Services adhere to a communications agreement, as defined collectively by one or more service-description documents.
  •          Service loose coupling: Services maintain a relationship that minimizes dependencies and only requires that they maintain an awareness of each other.
  •          Service abstraction: Beyond descriptions in the service contract, services hide logic from the outside world.
  •          Service reusability: Logic is divided into services with the intention of promoting reuse.
  •          Service autonomy: Services have control over the logic they encapsulate.
  •          Service statelessness: Services minimize resource consumption by deferring the management of state information when necessary
  •          Service discoverability: Services are supplemented with communicative meta data by which they can be effectively discovered and interpreted.
  •          Service composability: Services are effective composition participants, regardless of the size and complexity of the composition.
  •          Service granularity: A design consideration to provide optimal scope and right granular level of the business functionality in a service operation.
  •          Service normalization: Services are decomposed and/or consolidated to a level of normal form to minimize redundancy. In some cases, services are denormalized for specific purposes, such as performance optimization, access, and aggregation
  •          Service optimization: All else equal, high-quality services are generally preferable to low-quality ones.
  •          Service relevance: Functionality is presented at a granularity recognized by the user as a meaningful service.
  •          Service encapsulation: Many services are consolidated for use under the SOA. Often such services were not planned to be under SOA.
  •          Service location transparency: This refers to the ability of a service consumer to invoke a service regardless of its actual location in the network. This also recognizes the discoverability property (one of the core principle of SOA) and the right of a consumer to access the service. Often, the idea of service virtualization also relates to location transparency. This is where the consumer simply calls a logical service while a suitable SOA-enabling runtime infrastructure component, commonly a service bus, maps this logical service call to a physical service.

   

17 February 2014

Web services

          Web services can implement a service-oriented architecture. They make functional building-blocks accessible over standard Internet protocols independent of platforms and programming languages. These services can represent either new applications or just wrappers around existing legacy systems to make them network-enabled.  
     
         Each SOA building block can play one or both of two roles:

   Service provider
           The service provider creates a web service and possibly publishes its interface and access information to the service registry. Each provider must decide which services to expose, how to make trade-offs between security and easy availability, how to price the services, or (if no charges apply) how/whether to exploit them for other value. The provider also has to decide what category the service should be listed in for a given broker service and what sort of trading partner agreements are required to use the service.

      It registers what services are available within it, and lists all the potential service recipients. The implementer of the broker then decides the scope of the broker. Public brokers are available through the Internet, while private brokers are only accessible to a limited audience, for example, users of a company intranet.

          Furthermore, the amount of the offered information has to be decided. Some brokers     specialize in many listings. Others offer high levels of trust in the listed services. Some cover a broad landscape of services and others focus within an industry. Some brokers catalog other brokers. Depending on the business model, brokers can attempt to maximize look-up requests, number of listings or accuracy of the listings.

            The Universal Description Discovery and Integration (UDDI) specification defines a way to publish and discover information about Web services. Other service broker technologies include (for example) ebXML (Electronic Business using eXtensible Markup Language) and those based on the ISO/IEC 11179 Metadata Registry(MDR) standard.

Service consumer:
                  The service consumer or web service client locates entries in the broker registry using various find operations and then binds to the service provider in order to invoke one of its web services. Whichever service the service-consumers need, they have to take it into the brokers, bind it with respective service and then use it. They can access multiple services if the service provides multiple services.

      There are three aspects of web service development: 
                 Creating the web service
                 Creating a proxy
                 Consuming the web service
Creating the Web Service:
               A web service is an web application which is basically a class consisting of methods that could be used by other applications. It also follows a code-behind architecture like the ASP.Net web pages, although it does not have an user interface.
 Creating the Proxy:
              A proxy is a stand-in for the web service codes. Before using the web service, a proxy must be created. The proxy is registered with the client application. Then the client application makes the calls to the web service as it were using a local method.
              The proxy takes the calls, wraps it in proper format and sends it as a SOAP request to the server. SOAP stands for Simple Object Access Protocol. This protocol is used for exchanging web service data.When the server returns the SOAP package to the client, the proxy decodes everything and presents it to the client application.
 Consuming the web service:
              We are adding the web service as service reference in the application and using the web service 
 Implementation of Web Service

Image Control - Basic Web Control

   The image control is used for displaying images on the web page, or some alternative text, if the image is not available.
Basic syntax for an image control:
    <asp: Image Id=”Image1” runat=”server”>
Important Properties:
     Alternate text: Alternate text to be displayed
   Image Align: Alignment options for the control
   Image URL: Path of the image to be displayed by the control

Hyperlink - Basic Web Control

      The Hyperlink control is like the HTML <a> element.
Basic syntax for a hyperlink control:
       <asp: hyperlink id="hyperlink1" runat="server"> </asp:hyperlink>
Properties:

    ImageURL:Path of the image to be displayed by the control
    Navigate URL: Target link URL
    Text :The text to be displayed as the link
    Target:The window or frame which will load the linked page

Example for HyperLink Control


HTML View:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>asp.net HyperLink example: how to use</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Red">HyperLink example</h2>  
        <asp: HyperLink    ID="HyperLink1"   runat="server"      Text="Visit Flying Crow Page"  
         NavigateUrl="~/FlyingCrow.aspx"  >  
        </asp: HyperLink>  
        <br />  
        <asp: HyperLink    ID="HyperLink2"   runat="server"  >  </asp:HyperLink>  
    </div>  
    </form>  
</body>  
</html>  

ASPX Page:


OutPut:





Bulleted lists - Basic Web Controls

         The bulleted list control creates bulleted lists or numbered lists. These controls contain a collection of List Item objects that could be referred to through the Items property of the control.
Basic syntax of a bulleted list:
<asp:bulleted lists id="bulletedlist1" runat="server"></asp:bulleted lists>
Common Properties of the Bulleted List:
   Bullet Style:This property specifies the style and looks of the bullets
  
  Repeat Direction:It specifies the direction in which the controls to be repeated. The values available are horizontal and vertical ,default is Vertical

  Repeat Columns: It specifies  the number of columns to use when repeating the controls,default is 0



Sample for Bulleted List:


  1. <%@ Page Language="C#" %>  
  2.   
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  4.   
  5. <script runat="server">  
  6.   
  7. </script>  
  8.   
  9. <html xmlns="http://www.w3.org/1999/xhtml">  
  10. <head runat="server">  
  11.     <title>BulletedList Control Example</title>  
  12. </head>  
  13. <body>  
  14.     <form id="form1" runat="server">  
  15.     <div>  
  16.         <asp:BulletedList ID="BulletedList1" runat="server">  
  17.             <asp:ListItem>ColdFusion</asp:ListItem>  
  18.             <asp:ListItem>PHP</asp:ListItem>  
  19.             <asp:ListItem>Asp.Net</asp:ListItem>  
  20.             <asp:ListItem>JSP</asp:ListItem>  
  21.         </asp:BulletedList>  
  22.     </div>  
  23.     </form>  
  24. </body>  
  25. </html>  

Change BulletStyle Property 

You can change the Bullet Style property. It's support various format. Here a sample code.

  1. <form id="form1" runat="server">  
  2. <div>  
  3.  <asp:BulletedList ID="BulletedList1" runat="server" BulletStyle="Numbered">  
  4.   <asp:ListItem>ColdFusion</asp:ListItem>  
  5.   <asp:ListItem>PHP</asp:ListItem>  
  6.   <asp:ListItem>Asp.Net</asp:ListItem>  
  7.   <asp:ListItem>JSP</asp:ListItem>  
  8.  </asp:BulletedList>  
  9. </div>  
  10. </form>  




Radio Button List and Check Box List - Basic Web Controls

       A radio button list presents a list of mutually exclusive options. A check box list presents a list of independent options. These controls contain a collection of List Item objects that could be referred to through the Items property of the control.
Basic syntax for radio button list:
<asp:radiobuttonlisId="Radiobuttonlist1"runat="server"autopostback="true"  OnSleectedIndexChanged="Radiobuttonlist1_selectedindexchanged">
</asp: radiobuttonlist>
Basic syntax for check box list:
<asp:CheckboxlistId="CheckboxList1"Runat="Server"Autopostback="true" OnSleectedIndexChanged="CheckboxList1_selectedindexchanged"></asp:Checkboxlist >
Common Properties of Check Box and Radio Button Lists:
      Repeat Layout:This attribute specifies whether the table tags or the normal html flow to user while formatting the list when it is rendered.The default is table


     Repeat Direction:It specifies the direction in which the controls to be repeated.the values available are horizontal and vertical

    Repeat Columns:It specifies the number of columns to use when repeating the controls ,default is 0

List Item Collections -Basic Web Controls

        The ListItemCollection object is a collection of List Item objects. Each List Item object represents one item in the list. Items in a ListItemCollection are numbered from 0.
       When the items into a list box are loaded using strings like: lstcolor.Items.Add("Blue") . then both the Text and Value properties of the list item are set to the string value you specify. To set it differently you must create a list item object and then add that item to the collection.
       The List Item Collection Editor is used to add item to a drop-down list or list box. This is used to create a static list of items. To display the Collection Editor select Edit item from the smart tag menu, or select the control and then click the ellipsis button from the Item property in the Properties window.
Common Properties of List Item Collection:
       Item(Integer): A List Item object that represents the item at the specified index
       Count : The number of items in the collection 
Common methods of List Item Collection:
        Add(String): Adds a new item to the end of the collection and assigns the string parameter  to the text property of the item 

        Add(List Item):Adds new item to the end of the collection
     Insert(integer,string):Inserts an item at the specified index location in the collection,and assigns the string parameter to the text property of the item 
      Insert(integer,List Item):Inserts the item at the specified index location in the collection
   
      Remove(String): Removes he item with the text value same as the string 
       
      RemoveAt(Integer): Removes the item at the specified index as the integer
   
      Clear :Removes all the items of the collection
  
      FindByValue(String): Returns the item whose value is same as the string 
  
      FindByValue(Text):Returns the item  whose text is same as the string