You are on page 1of 36

WEB SERVICES

Technologies Covered…
 Web Services
 J2EE
 .NET
What Is a Web Service?

 Remote access to Data and Process


 Reusable Unit of Business Work
 The results can be presented in any
fashion required HTML, SWING,
MFC,WML, XML, etc,
Definition
 “A collection of functions that are
packaged as a single entity and published
to the network for use by other programs.
Web services are building blocks for
creating open distributed systems, and
allow companies and individuals to quickly
and cheaply make their digital assets
available worldwide”
Technical Details
Web Services Architecture
Web Services Framework

 Framework can be described in terms of

 What goes “on the wire”:


Formats and protocols.

 What describes what goes on the wire:


Description languages.

 What allows us to find these descriptions:


Discovery of services.
Service Oriented
Architecture.
 Client queries UDDI registry for services either by
name, category, identifier or specification.
 Once located, the client obtains information about
the location of a WSDL document from the UDDI
registry
 WSDL document contains information about how
to contact web services and format of request
messages in XML schema.
 Client then creates a SOAP message in
accordance with XML schema found in WSDL and
sends request to the host.
Processes of Web Services
Travel Service
Registry

Desktop
Computer
Airline Ticket
Reservation

Company
Rental Car
Reservation
Service
Requestor

Travel Reservation
PDA Service Provider

Hotel Reservation
Business Case Example
Old work flow
2. Employee requests
records from the
state
1. Insurance claim is
entered into
system

4. Employee copies
records into system
3. State mails records
one week later

New work flow


1. Insurance claim is 2. System requests

b Services
entered into records from the
system state

3. State immediately
sends records to
We
system
Steps in Web Services Usage

 Step1: Developing Web Service


 Step 2: Describing Web Service
 Step 3: Publishing Web Service
 Step 4: Finding a Web Service
 Step 5: Binding a Web Service
Step1: Developing Web Service

Service provider exposes actual


service in the Web
 Http & XML interface
 Developed in Java or C# or VB.NET
 It can be deployed in either J2EE or .NET
Step 2: Describing Web Service
 Provider Describes service using WSDL –
Web Service Description Language
 An abstract definition of web service
endpoints is described using WSDL
 Web Services Description Language is
an XML grammar for describing web
services as collections of message-
enabled endpoints or ports
 The association of a concrete protocol
and data format specifications
constitutes a Binding
Step 3: Publishing Web Service
 Represents a service provider
publishing a service to an external
repository.
 Once such a service has been exported to a
registry, it can then be used by a client.
 Service provider publishes services in
UDDI ( Universal Description Discovery
Integration) – (IBM, Microsoft, HP)
 UDDI – public registry
 Group of web-based registries (operator Sites)
 Expose information about a business and its
technical interface & APIs
 JAXR is a Java API for interoperating with
multiple registry types
Step 4: Finding a Web Service
 Looking up a service from a repository and
returning information about a service,
respectively.
 Information, such as the format of the procedure
calls and the address of a service provider, would
normally be provided, amongst other details.
 Service information in UDDI - Two
Types of Search
 Design Time – Service Provider interacts with
registry – checks service available
 Run Time – Service consumer looking for
binding info required to invoke service
Step 5: Binding a Web Service
 Service consumer will access – using
service info obtained from UDDI
 The client binding to an underlying service
 Then accessing that service to use whatever
functionality the service provides.
J2EE
 J2EE is a collection of Enterprise
Technologies.
 The Java 2 Platform, Enterprise Edition
(J2EE) was designed to simplify complex
problems with the development,
deployment, and management of multi-
tier enterprise solutions.
 J2EE is a standard, not a product.
 The J2EE architecture is based on the
Java programming language.
J2EE Technologies
 EJB
 Java mail
 RMI-IIOP
 JNDI
 JMS
 JDBC
 JTA
 JCA
 Servlets
 JSP
 IDL
Service Definition Interface
package hello;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface HelloIF extends Remote
{
public String sayHello (String s) throws
RemoteException;
}
Implementation Class
package hello;
public class HelloImpl implements HelloIF
{
public String message ="Hello";
public String sayHello(String s)
{
return message + s;
}
}
Building the service
 The service is compiled using the tool wscompile
and the configuration file.
 <?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns="http://java.sun.com/xml/ns/jax-
rpc/ri/config">
<service name="MyHelloService"
targetNamespace=“New"
typeNamespace=“New" packageName="hello">
<interface name="hello.HelloIF"/>
</service>
</configuration>
Deploying the Service

 The service can be deployed using


the deploytool provided by the J2EE
Application Server.
 The WSDL file contains the service
endpoint and other details.
 The client Jar file should be
developed in order to enable the
client to access the server.
Web Service Client
import javax.xml.rpc.Stub;
public class HelloClient
{
public static void main(String[] args)
{
Stub stub = createProxy();
HelloIF hello = (HelloIF)stub;
System.out.println(hello.sayHello("Duke!"));
}
catch (Exception ex)
{ ex.printStackTrace(); }
} private static Stub createProxy()
{
return (Stub)(new MyHello_Impl().getHelloIFPort());
}
}
.NET
 Microsoft.NET is product suite that
enables organizations to build smart,
enterprise-class web services.
 .NET is a product strategy, whereas
J2EE is a standard to which products
are written.
Developing Web Services in
.NET
 Web Services are developed using
either VB.NET or C# in the following
steps
 Code the interface and the
implementation in a file having
extension .asmx (VB.NET or C#)
 Store the file in a virtual directory of IIS.
 Access the file via a Web Browser.
 Compilation and Deployment are done
automatically.
Simple Web Service in C#
<%@ WebService class="FirstService.Service1"
Language="C#"%>
using System;
using System.Web;
using System.Web.Services;
namespace FirstService
{
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
Simple Web Service in VB.NET
<%@ WebService Class="Hello" %>
imports System.Web.Services
imports System
imports System.Data
<WebService(Namespace:="http://localhost/
")>
Public Class Hello
<webMethod()>
public Function sayHello() as
String
return "Hello World"
End function
End Class
Future of Web Services- Personalized
Web Services
 Personalization achieved using
 User profiles
 Monitoring user behavior
 Devices and context to customize web services for
achieving metrics like Quality of Experience
 Involve providing and meeting service
performance on user side
 Creation of third party rating agencies – register
user experiences
 Render web services “customer friendly”

You might also like