2. What’s a Web Service?
● A web service is just a web page meant for a computer to
request and process.
● More precisely, a Web service is a Web page that’s meant
to be consumed by an autonomous program as opposed
to a Web browser or similar UI tool.
● Even more precisely the name it self indicates that its a
service which is available over the Web, that’s it.
3. Examples of web service
● An e-commerce company can use a shipper’s
web service to calculate the exact cost of a
shipment.
● National weather forecasters use them to
supply data to web-sites and news
organizations.
● Stock prices are provided this way by major
exchanges and corporations.
4. Benefits of Web Services
● Simple – easily supported on many platforms
● Loosely Coupled – the interface can be extended and
new methods added without affecting clients as long as
old methods and parameters are still provided
● Stateless – a request is made, then result is returned
and the connection closes, no permanent connection
● Firewall Friendly – uses HTTP, not usually blocked
5. When to use Web Services
● Cross platform – i.e. Communicate between a
Java app and a .NET app
● Cross trust boundaries – between two
unrelated organizations
● Future considerations – if there is a possibility
that the logic may have to support third party
integration
● Comunication between IOS and java.
6. When to Avoid Web Services
● .Net to .Net – there are better ways to
communicate between servers, such as .NET
remoting
● .Net Apps – rather than provide a Service, if two
apps need the same logic create a class library
assembly compiled to a DLL, which is then
used in both apps.
7. Types of web service
● SOAP(Simple object access protocol)
● REST(Representational state transfer)
We have different type of specifications to implement SOAP and REST services.
● AX-RS provides the implementation of RESTful web services, JAX-RS is a
specification for RESTful Web Services with Java and it is given by Sun. Since it is a
specification, other frameworks can be written to implement these specifications, and
that includes Jersey from Oracle, Resteasy from Jboss, CXF from Apache bla bla.
● JAX-WS, Apache Axis2 provides the implementation for SOAP
● Apache CXF provides implementation for SOAP and RESTful services both.
8. REST web service
● What ever the data/response we will get from
the server is known as Resource
● Each resource can be accessed by its URI’s.
● We can get the resource from RESTful service
in different formats like,
HTML,XML,JSON,TEXT,PDF and in the Image
formats as well, but in real time we mainly we
will prefer JSON.
9. REST web service
● REST always prefers to choose HTTP as it a
stateless protocol.
10. REST web service
RESTful used 4 main HTTP methods…
● GET - Retrieve Data
● POST- Create/Insert Data
● PUT- Update Data
● DELETE- Delete Data
12. How RESTful Web Services Extract
Input Parameters
● @PathParam,@QueryParam,@MatrixParam are parameter annotations
which allows us to map variable URI path fragments into your method
call.
● @PathParam URL Syntax
http://localhost:8080/<Rest Service Name>/rest/customers/100/ccs.
● @QueryParam URL Syntax
http://localhost:8080/…/rest/customers?custNo=100&custName=ccs
● @MatrixParam URL Syntax
http://localhost:8080/…/rest/customers;custNo=100;custName=ccs..
13. SOAP web service
●
SOAP stands for Simple Object Access Protocol
●
SOAP is a communication protocol
●
SOAP is for communication between applications
●
SOAP is a format for sending messages
● SOAP communicates via Internet
● SOAP is platform independent
● SOAP is language independent
● SOAP is based on XML
● SOAP is simple and extensible
● SOAP allows you to get around firewalls
● SOAP is a W3C recommendation
14. SOAP web service
Why SOAP?
●
It is important for application development to allow Internet communication between programs.
●
Today's applications communicate using Remote Procedure Calls (RPC) between objects like
DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and
security problem; firewalls and proxy servers will normally block this kind of traffic.
●
A better way to communicate between applications is over HTTP, because HTTP is supported
by all Internet browsers and servers. SOAP was created to accomplish this.
●
SOAP provides a way to communicate between applications running on different operating
systems, with different technologies and programming languages.
15. SOAP web service
SOAP Building Blocks
● A SOAP message is an ordinary XML document containing the
following elements:
● An Envelope element that identifies the XML document as a
SOAP message
● A Header element that contains header information
● A Body element that contains call and response information
● A Fault element containing errors and status information
16. SOAP web service
WSDL
● “ Web Service Description Language” is an XML document that
defines the service interface, protocol bindings, and service
endpoint addresses
● Uses XML schema to define XML types
● Typically uses SOAP to bind the messaging protocol
UDDI
● “ Universal Description, Discovery and Integration” is a
repository/database of services (e.g. defined by WSDLs)