Service Oriented Architecture or SOA for short is a new architecture for the development of loosely coupled distributed applications. In fact service-oriented architecture is collection of many services in the network. These services communicate with each other and the communications involves data exchange & even service coordination. Earlier SOA was based on the DCOM or Object Request Brokers (ORBs). Nowadays SOA is based on the Web Services.
Broadly SOA can be classified into two terms: Services and Connections.
Services:
A service is a function or some processing logic or business processing that is well-defined, self-contained, and does not depend on the context or state of other services. Example of Services are Loan Processing Services, which can be self-contained unit for process the Loan Applications. Other example may be Weather Services, which can be used to get the weather information. Any application on the network can use the service of the Weather Service to get the weather information.
Connections:
Connections means the link connecting these self-contained distributed services with each other, it enable client to Services communications. In case of Web services SOAP over HTTP is used to communicate the between services.
The following figure is a typical example of the service-oriented architecture. It shows how a service consumer sends a service request to a service provider. After accepting the request, service provider send a message to the service consumer. In this case a service provider can also be a service consumer.
Different Technologies Used:
SOA is much different from point-to-point architectures. SOA comprise loosely coupled, highly interoperable application services. These services can be developed in different development technologies (such as Java, .NET, C++, PERL, PHP), the software components become very reusable i.e. the same C# (C Sharp) service may be used by a Java application and / or any other programming language. WSDL defines an standard, which encapsulates / hides the vendor / language specific implementation from the calling client / service.
SOA definitions
(From http://en.wikipedia.org/wiki/Service-oriented_architecture )
(From http://en.wikipedia.org/wiki/Service-oriented_architecture )
Term | Definition / Comment |
---|---|
service | (Ideally) a self-contained, stateless business function which accepts one or more requests and returns one or more responses through a well-defined, standard interface. Services can also perform discrete units of work such as editing and processing a transaction. Services should not depend on the state of other functions or processes. The technology used to provide the service, such as a programming language, does not form part of this definition. |
orchestration | Sequencing services and providing additional logic to process data. Does not include data presentation. |
stateless | Not depending on any pre-existing condition. In a SOA, services should not depend on the condition of any other service. They receive all information needed to provide a response from the request. Given the statelessness of services, service consumers can sequence (orchestrate) them into numerous flows (sometimes referred to as pipelines) to perform application logic. |
provider | The function which performs a service in response to a request from a consumer. |
consumer | The function which consumes the result of a service supplied by a provider. |
discovery | Service oriented architecture relies on the ability to identify services and their capabilities. Therefore, a SOA depends on a directory which describes the services available in its domain. |
binding | The relationship between a service provider and consumer is dynamic; it is established at runtime by a binding mechanism. |
Why SOA?
SOA architecture enables seamless Enterprise Information Integration. Here are some of the Benefits of the Service Oriented Architecture:
- Due to its platform independence, it allows companies to use the software and hardware of their choice .
- There is no threat of vendor lock-in
- SOA enables incremental development, deployment, and maintenance.
- Companies can use the existing software (investments) and use SOA to build applications without replacing existing applications
- The training costs are low, so the available labor pool can be used for running the applications
The next generation of distributed computing has arrived. A Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests.
Historically speaking, remote access to binary units required platform-specific and sometimes language-specific protocols. For example, DCOM clients access remote COM types using tightly coupled RPC calls. CORBA requires the use of tightly coupled protocol referred to asInternet Inter-ORB Protocol (IIOP), to activate remote types. Enterprise JavaBeans (EJBs) requires a Remote Method Invocation (RMI) Protocol and by and large a specific language (Java). Thus each of these remote invocation architectures needs proprietary protocols, which typically require a tight connection to the remote source.
One can access Web services using nothing but HTTP. Of all the protocols in existence today, HTTP is the one specific wire protocol that all platforms tend to agree on. Thus , using Web services, a Web service developer can use any language he wish and a Web service consumer can use standard HTTP to invoke methods a Web service provides. The bottom line is that we have true language and platform integration . Simple Object Access Protocol (SOAP) andXML are also two key pieces of the Web services architecture.
What is a Web ServiceWeb services constitute a distributed computer architecture made up of many different computers trying to communicate over the network to form one system. They consist of a set of standards that allow developers to implement distributed applications - using radically different tools provided by many different vendors - to create applications that use a combination of software modules called from systems in disparate departments or from other companies.
A Web service contains some number of classes, interfaces, enumerations and structures that provide black box functionality to remote clients. Web services typically define business objects that execute a unit of work (e.g., perform a calculation, read a data source, etc.) for the consumer and wait for the next request. Web service consumer does not necessarily need to be a browser-based client. Console-baed and Windows Forms-based clients can consume a Web service. In each case, the client indirectly interacts with the Web service through an intervening proxy. The proxy looks and feels like the real remote type and exposes the same set of methods. Under the hood, the proxy code really forwards the request to the Web service using standard HTTP or optionally SOAP messages.
Web Service StandardsWeb services are registered and announced using the following services and protocols. Many of these and other standards are being worked out by the UDDI project, a group of industry leaders that is spearheading the early creation and design efforts.
Universal Description, Discovery, and Integration (UDDI) is a protocol for describing available Web services components. This standard allows businesses to register with an Internet directory that will help them advertise their services, so companies can find one another and conduct transactions over the Web. This registration and lookup task is done using XML andHTTP(S)-based mechanisms.
Simple Object Access Protocol (SOAP) is a protocol for initiating conversations with a UDDIService. SOAP makes object access simple by allowing applications to invoke object methods or functions, residing on remote servers. A SOAP application creates a request block in XML, supplying the data needed by the remote method as well as the location of the remote object itself.
Web Service Description Language (WSDL), the proposed standard for how a Web service is described, is an XML-based service IDL (Interface Definitition Language) that defines the service interface and its implementation characteristics. WSDL is referenced by UDDI entries and describes the SOAP messages that define a particular Web service.
ebXML (e-business XML) defines core components, business processes, registry and repository, messaging services, trading partner agreements, and security.
Implementing Web ServicesHere comes a brief step-by-step on how a Web service is implemented.
- A service provider creates a Web service
- The service provider uses WSDL to describe the service to a UDDI registry
- The service provider registers the service in a UDDI registry and/or ebXML registry/repository.
- Another service or consumer locates and requests the registered service by querying UDDI and/or ebXML registries.
- The requesting service or user writes an application to bind the registered service using SOAPin the case of UDDI and/or ebXML
- Data and messages are exchanged as XML over HTTP
Even though Web services are being built using existing infrastructure, there exists a strong necessity for a number of innovative infrastructures. The core architectural foundation of Web services are XML, XML namespaces, and XML schema. UDDI, SOAP, WSDL, ebXMLand security standards are being developed in parallel by different vendors
Web Services Technologies and ToolsThere are a number of mechanisms for constructing Web services. Microsoft has come out with a new object-oriented language C# as the development language for Web services and .NET framework. Microsoft has an exciting tool called Visual Studio .NET in this regard. The back end database can be Microsoft SQL Server 2000 in Windows 2000 Professional.
Sun Microsystems has its own set of technologies and tools for facilitating Web services development. Java Servlets, Java Server Pages (JSPs), Enterprise JavaBeans (EJB) architecture and other Java 2 Enterprise Edition (J2EE) technologies play a very critical role in developing Web services.
There are a number of tools for developing Web services. They are Forte Java IDE, Oracle JDeveloper, and WebGain Studio.
Sun Microsystems has taken an initiative called Sun ONE (Open Network Environment) and is planning to push Java forward as a platform for Web services. It is developing Java APIs for XML-based remote procedure calls and for looking up services in XML registries - two more JAX family APIs: JAX/RPC (Java API for XML Remote Procedure Calls) and JAXR (Java API for XML Registries). These will wrap up implementations of Web services standards, such as SOAP and UDDI.
IBM also for its part has already developed a suite of early-access tools for Web services development. They are Web Services Toolkit (WSTK), WSDL Toolkit, and Web Services Development Environment (WSDE).
Apache Axis is an implementation of the SOAP ("Simple Object Access Protocol") submissionto W3C.
From the draft W3C specification:
SOAP is a lightweight protocol for exchanging structured information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.
Apache Axis is an Open Source SOAP server and client. SOAP is a mechanism for inter-application communication between systems written in arbitrary languages, across the Internet. SOAP usually exchanges messages over HTTP: the client POSTs a SOAP request, and receives either an HTTP success code and a SOAP response or an HTTP error code. Open Source means that you get the source, but that there is no formal support organization to help you when things go wrong.
ConclusionFor the last few years, XML has enabled heterogeneous computing environments to share information over the Web. It now offers a simplified means by which to share process as well. From a technical perspective, the advent of Web services is not a revolution in distributed computing. It is instead a natural evolution of XML application from structured representation of information to structured representation of inter-application messaging.
Prior to the advent of Web services, enterprise application integration (EAI) was very difficult due to differences in programming languages and middleware used within organizations. This led to the situation where interoperability was cumbersome and painful. With the arrival ofWeb services, any application can be integrated as long as it is Internet-enabled.
It is difficult to avoid the popularity and hype that is surrounding Web services. Each software vendor has some initiative concerning Web services and there is always great speculation about the future of the market for them. Whichever way it turns out, Web service architectures provide a very different way of thinking about software development. From client-server to n-tier systems, to distributed computing, Web service applications represent the culmination of each of these architectures in combination with the Internet.
A Web service is a unit of managed code that can be remotely invoked using HTTP, that is, it can be activated using HTTP requests. So, Web Services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program.
Connecting Different Applications: Web Services allows different applications to talk to each other and share data and services among themselves. Other applications can also use the services of the web services. For example VB or .NET application can talk to java web services and vice versa. So, Web services is used to make the application platform and technology independent.
Standardized Protocol: Web Services uses standardized industry standard protocol for the communication. All the four layers (Service Transport, XML Messaging, Service Description and Service Discovery layers) uses the well defined protocol in the Web Services protocol stack. This standardization of protocol stack gives the business many advantages like wide range of choices, reduction in the cost due to competition and increase in the quality.
Low Cost of communication: Web Services uses SOAP over HTTP protocol for the communication, so you can use your existing low cost internet for implementing Web Services. This solution is much less costly compared to proprietary solutions like EDI/B2B.
Support for Other communication means: Beside SOAP over HTTP, Web Services can also be implemented on other reliable transport mechanisms. So, it gives flexibility use the communication means of your requirement and choice. For example Web Services can also be implemented using ftp protocol (Web services over FTP).
Loosely Coupled Applications: Web Services are self-describing software modules which encapsulates discrete functionality. Web Services are accessible via standard Internet communication protocols like XML and SOAP. These Web Services can be developed in any technologies (like c++, Java, .NET, PHP, Perl etc.) and any application or Web Services can access these services. So, the Web Services are loosely coupled application and can be used by applications developed in any technologies. For example, I have heard of people developing Web Services using Java technologies and using the Web Services in VB or .NET applications.
Web Services Sharing: These days due to complexness of the business, organizations are using different technologies like EAI, EDI, B2B, Portals etc. for distributing computing. Web Services supports all these technologies, thus helping the business to use existing investments in other technologies.
Web Services are Self Describing: Web Services are self describing applications, which reduces the software development time. This helps the other business partners to quickly develop application and start doing business. This helps business to save time and money by cutting development time.
Automatic Discovery: Web Services automatic discovery mechanism helps the business to easy find the Service Providers. This also helps your customer to find your services easily. With the help of Web Services your business can also increase revenue by exposing their own Web Services available to others.
Business Opportunity: Web Services has opened the door to new business opportunities by making it easy to connect with partners.
Web Services Introduction
Before understanding why web services are popular or so important, you should first assess ‘What is Web Services, what’s its use and how does it work?’ The nature and functionality of web services have made it very popular. Nowadays, our business systems have matured, transparent and more logical and high tech, and all for these are because of web services.
Definition
Web services are the amalgamation of eXtensible Markup Language (XML) and HyperText Transfer Protocol HTTP that can convert your application into a Web-application, which publish its function or message to the rest of the world.
In other words, we can say, web services are just Internet Application Programming Interfaces (API) that can be accessed over a network, such as Internet and intranet, and executed on a remote system hosting the requested services.
Web-applications are simple applications that run on the web. Web services are browsers and operating system independent service, which means it can run on any browser without the need of making any changes. Web Services take Web-applications to the Next Level.
The World Wide Web Consortium (W3C) has defined the web services. According to W3C, “Web Services are the message-based design frequently found on the Web and in enterprise software. The Web of Services is based on technologies such as HTTP, XML, SOAP, WSDL, SPARQL, and others.”
The Elements of Web ServicesWeb services use XML to code and to decode data, and SOAP to transport it (using open protocols). Besides these, HTTP, Web Services Description Language (WSDL), Universal Description, Discovery and Integration (UDDI), and SPARQL are the elements of Web Services.
To understand clearly about Web Services, it is mandatory to have some brief knowledge of web services elements.
HTTP
HyperText Transfer Protocol in short HTTP is the most widely used protocol by World Wide Web. It defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands.
One of the shortcomings of HTTP is that it is a stateless protocol, which means each command is executed independently, without any knowledge of the commands that came before it. This shortcoming has been resolved in new technologies includes ActiveX, Java, JavaScript and cookies.
Simple Object Access Protocol (SOAP)
SOAP is a simple XML-based protocol that allows to communicate applications information over HTTP without the dependency of OS platform. SOAP uses HTTP and XML as the mechanisms for information exchange.
Universal Description, Discovery and Integration (UDDI)
Universal Description, Discovery and Integration in short UDDI is a web based distributed directory like traditional phone book's yellow and white pages that enables businesses to list themselves on the Internet and discover each other. It defines a registry service – a Web service that manages information about service providers, service implementations, and service metadata – for Web services and for other electronic and non-electronic services.
The service providers can use UDDI to advertise the services they offer while service consumers can use UDDI to discover services.
Web Services Description Language (WSDL)
Web Services Description Language (WSDL)
The WSDL refers to Web Services Description Language, is an XML based protocol used for sending and receiving the information through decentralized and distributed environments. WSDL is an integral part of UDDI that was developed jointly by Microsoft and IBM.
It defines what services are available in its Web service and also defines the methods, parameter names, parameter data types, and return data types for the Web service. The WSDL document is quite reliable and applications that use web services accept it
SPARQLSPARQL refers to SPARQL Protocol and RDF Query Language is an RDF query language that defines a standard query language and data access protocol for use with the Resource Description Framework (RDF) data model. It works for any data source that can be mapped to RDF. SPARQL allows a query to be consisted of triple patterns, conjunctions, disjunctions, and optional patterns. It is standardized by the RDF Data Access Working Group (DAWG) of the W3C, and is considered a key semantic web technology.
Uses of Web ServicesWeb services are a set of tools that can be used in a number of ways most commonly in three styles:
- Remote Procedure Calls
- Service-oriented architecture
- Representational state transfer
Moreover, it is also used as Reusable application-components and Connect existing software.
Remote procedure calls (RPC)The Remote procedure calls Web services present a distributed function call interface, which is familiar to many developers. Typically, the basic unit of RPC Web services is the WSDL operation.
Service-oriented architecture (SOA)Under Service-oriented architecture (SOA) Web services is used to implement an architecture in which the basic unit of communication is a message, rather than an operation. This is often referred to as "message-oriented" services. Major software vendors and industry analysts support the SOA Web Services.
Representational state transfer (REST)The Representational State Transfer (REST) Web Services attempts to describe architectures based on REST can use WSDL to describe SOAP messaging over HTTP, which defines the operations. REST describes operations, can be implemented as an abstraction purely on top of SOAP or can be created without using SOAP at all.
In Reusable application-components uses Web Services offers most frequently used services like currency conversion, weather reports, language translation and much more.
In Connect existing software, Web Services offers you to exchange data between different applications and different platforms. In this type of uses, you can solve the interoperability problem by giving different applications a way to link their data.
Now, you have assessed why web services is so popular and why it is widely in use.
In this section we introduced you with the Web services. In next section you will learn about the importance of Web services.WebService with database Mysql
User Registration WebServices Example
In this tutorial we will develop a simple user registration Webservices. The user registration/account registration form will be presented to the user. Once user fills in the form and clicks on the "OK" button, the serverside JSP will call the webservice to register the user.
This webservices will expose the insert user operation which will be used by the JSP client to register the user. We will use the NetBeans 6.1 IDE to develop and test the application.
The MySQL database is used to save the user registration data. You can modify the code to use any database of your choice. The existing webservices can also be modified to use the Hibernate or any other ORM technologies. You can also use the Entity beans to persist the data into database.
Software required to develop and run this example:
- JDK 1.6
- NetBeans 6.1
- MySQL Database 5 or above
MySql Database Configuration In NetBeansLet's configure MySQL database in teh NetBeans IDE and then create the required table into database.
Step 1:
- Click on the service tab in NetBeans as shown below in Fig 1.
Step 2:
- Right Click on the Databases
- Select New Connection as shown below in Fig 2.
Fig. 2.
Step 3:
- It opens a dialog box for the mysql configuration.
- Type the driver name, url , user name and password as shown below in Fig. 3.
Fig. 3
Step 4:
- Click on the Ok button .
- Now expand the Newly created database connection.
- It shows the all the tables of the database test as shown below in Fig 4.
Fig. 4
Step 5:
- Create a table named login.
- Right Click on the Tables and select Create table
as shown below in Fig 5
Fig. 5
Step 6:
- It opens a dialog box for giving the fields name of the table
- Now give the field name and data type as shown below in Fig 6.
Fig. 6
Step 7: - Click on the Ok
- It creates the table login in the test database.
Creating the WebService program for Account creation
Step 8:
- Open the netbeans 6.1
- Creat a new web project as shown below in Fig 7.
Fig. 7
Step 9:
- Type the project Name as MyAccount
- Click on the next button as shown below in Fig 8.
Fig. 8
Step 10:
- Select the server as Glassfish
- Click on the Next and then finish button as shown below in Fig 9.
Fig. 9
Step 11:
- It creates a Web Project named MyAccount.
Creating the WebService
Step 12:
- Right Click on the project MyAccount
- Select New-->WebService as shown below in Fig 10.
Fig. 10
Step 13: - Type the name of the WebService as myaccount with the package as mypack.
- Click on the Finish button as shown below in Fig 11.
Fig. 11
Step 14:
- It creates a WebService application in design view
- Click on the Add operation as shown below in Fig 12.
Fig. 12Step 15:
- In the dialog box type all parameter names.
- Also select the appropriate data type.
- Click on Ok as shown below in Fig 13.
Fig. 13
Step 16:
- It creates a WebService application
- Click on the source tab as shown below in the Fig 14.
Fig. 14
Step 17:
- Now create the database source
- Right Click in the source code of myaccount.java
- Select the Enterprise Resources-->Use Database as shown below in Fig 15.
Fig. 15
Step 18:
- In the choose database select the Add button as shown below in Fig 16.
Fig. 16
- It opens a Add Data Source Reference.
- Type the Reference Name as data1
- For Project Data Sources Click on the Add button as shown below in Fig 17.
Fig. 17
Step 20:
- In the Crea Data Source type thye jndi name as jndi1
- In the database connection select the newly created database connction for the mysql.
as shown below in Fig 18.
Fig. 18
Step 21:
- Click on the Ok button
- It creates the database connection gives the dialog box as shown below.
- Click on the Ok button as shown below in Fig 19.
Fig. 19
Step 22:
- It creates the datasource data1 with the resource name as data1 in the code
- Edit the code and give the database connection, statement for the mysql connectivity
as shown below.
package mypack;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;
@WebService()
public class myaccount {
@Resource(name = "data1")
private DataSource data1;
@WebMethod(operationName = "insert")
public String insert(@WebParam(name = "uname") String uname,
@WebParam(name = "fname") String fname, @WebParam(name = "lname") String lname,
@WebParam(name = "location") String location,
@WebParam(name = "phone") String phone, @WebParam(name = "credit") String credit,
@WebParam(name = "dl") String dl) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
"root", "");
PreparedStatement st =
con.prepareStatement("insert into login values(?,?,?,?,?,?,?)");
st.setString(1, uname);
st.setString(2, fname);
st.setString(3, lname);
st.setString(4, location);
int ph = Integer.parseInt(phone);
st.setInt(5, ph);
int cr = Integer.parseInt(credit);
st.setInt(6, cr);
int d1 = Integer.parseInt(dl);
st.setInt(7, d1);
st.executeUpdate();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return "record inserted";
}
}
Step 23:
- Now deploy the project
- Right click on the project
- Select Undeploy and Deploy as shown below in Fig 20.
- It builds and deploys the MyAccount Web project on the glassfish server.
Fig. 20
Step 24:
- After deploying now we can test the Web Service created
- Right click on the myaccount webservice
- Select Test Web Service as shown below in Fig 21.
Step 25:
- It runs the deployed webservice in the firefox browser.
- Type the value and click on the insert button as shown below in Fig 22.
Step 26:
- After clicking on the insert button it insert the values into the login table
- It open new window and displays the Metrhod parameters, SOAP request and response
as shown below in Fig 23.
Fig. 23
Step 27:
Check the data in the database table
- In the service tab select the mysql connection
- In its table node right click on the table login
- Select the view data as shown below in Fig 24. Fig. 24
Step 27:
- It opens a new window
- Then displas the data as shown below in Fig. 25.
Fig. 25
Making the client of the WebService
Step 28:
- Create a new Web Project
- Type the name as MyAccountClient as shown below in Fig.26.
Fig. 26
- Click on the next button
- Select the server as glassfish as shown below in Fig. 27.
Fig. 27
Step 30:
- Click on the finish button
- It creates a web rpoject with a index.jsp file
- In the index.jsp design it with form and all its fileds
- Give the form action as Client.jsp as shown below in Fig 28.
Create WebService Client
Step 1:
- Right Click on the MyAccountClient
- Select WebService Client as shown below in Fig.28.
Fig. 28
Step 2:
- In the dialog box click on the browse button
as shown below in Fig 29.
Fig. 29
Step 3:
- Select the myaccount webservice.
- Click on the OK button as shown below in Fig 30.
Fig. 30
Step 4: - Now project is containing the WSDL file url.
- Click on the Ok button as shown below in Fig 31.
Fig. 31
Step 5:
- Right Click in the Client.jsp
- Select Web Service Client Resources-->Call WebService Operation
as shown below in Fig 32.
Fig. 32
Step 5:
- Select the insert operation as shown below in Fig .33.
Fig. 33
Step 6: - After insert opoeration the code becomes like as shown below in Fig 34.
Fig. 34
Step 7:
- Deploy the MyAccountClient
- Right Click and select Undeplo and Deploy as shown below in Fig.35.
Fig. 35
Step 8:
- After deployment run the project.
- Right Click and select the run as shown below in Fig 36.
Fig. 36
Step 9: - It runs the index.jsp in the browser as shown below in Fig 37.
- Put the data and click on the ok button
Fig. 37
Step 10:
- After this click values get inserted in the database table
- The message comes as record inserted as shown below in Fig.38
Fig. 38
Step 11: - See the data inserted in the table.
- In the service tab select the connection created for mysql.
- In the table node select the login
- Right Click and select the view data as shown below in Fig. 39.
Fig. 39
Step 12:
- It displays the record inserted as shown below in Fig 40.
Fig. 40
Thanks for your information. very good article.
ReplyDeleteSOA Training in Hyderabad
SOA Online Training