Web Service 101

Download Report

Transcript Web Service 101

Web Service
All the Service describe by UDDI
Service
Registry
find
http://www.ibm.com/services/uddi
http://www.ibm.com/services/uddi/testregistry
http://uddi.microsoft.com
http://test.uddi.mirosoft.com
hp – available soon
Publish
SOAP on HTTP
Service
Requestor
Service
provider
Bind
UDDI (xml schemas)
UDDI- Universal Description, Discovery, and Integration
• Programmatic descriptions of businesses and
the services supported
• Programmatic descriptions of web service
specifications
• Programming model & schema
UDDI Business Registry
Businesses register public information about themselves
White pages
Business name, Text description, Contact info,
Known identifiers
Yellow pages
Business categories (standard taxonomies)
Green pages
Specify how to bind to a service provider.
Technical info about service (how to invoke
their services) – a point to WSDL
UDDI by examples
Two examples in UDDI registry
http://uddi.microsoft.com
1. Flower (a regular service)
2. Xmethods (provides more than
one web services, each one is
described in a WSDL file)
WSDL
WSDL- Web Service Description Language (an xml
vocabulary that is used to define the service interface for a
web service)
• Service interface detail
• Access protocol
• Contact endpoint (http://www.xmethods.net/detail.html?id=5 )
Service
Implementation
Definition
Service
Port
Binding
Service
Interface
Definition
PortType
Message
Type
url to accept the
soap request
WSDL Examples
Examples from www.xmethods.net
Service Name: Joke of the Day
Description: Provides a random joke on each execution.
WSDL URL:
http://services.xmltoday.com/vx_engine/wsdl_publish.vep/joke.wsdl
Service Name: Sun/Moon rise and set data
Description: Sunrise, sunset, moonrise, moonset
for a given latitude, longitude, date and time bias.
WSDL URL:
http://www.armyaviator.com/cgi-bin/astro.exe/wsdl/IAstro
SOAP
Simple Object Access Protocol (SOAP) is a
lightweight protocol that defines a uniform way of
passing XML-encoded data. (It also defines a way to
perform remote procedure using HTTP as the underlying
communication protocol)
http headers
soap message
soap header
soap Envelope
soap body
SOAP
Header
• Use for authentication, transaction
management, payment, encryption etc.
Body
• Special defines one body entry: Fault
<SOAP-ENV: Fault>
<faultcode>SOAP-ENV:server</faultcode>
<faultstring>Method’s getXXX is not supported.</ faultstring>
<faultactor>/xxx/xxx.jsp</ faultactor>/
</SOAP-ENV: Fault>
SOAP Message
POST /WeatherServioce HTTP/1.1
Host:www.weatherservice.com
Content-Type: text/xml; charset=“utf-8”
Content-Length: nnnn
SOAPAction: “Some-URL”
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”
SOAP-ENV:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Body>
<m:GetWeather xmlns:m=‘Some-URL’>
<city>Seattle</city>
<state>WA</state>
</m:GetWeather>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Web Services Stack
Service Description
Messaging
Transport
internet
Security
Workflow, Choreography
Management
Routing & Attachments
Quality of Service (QoS)
Service Negotiation
Web Service
• Currently most service entry (>95%) in UDDI
registry are not web based service.
• In the future there will be private vertical
UDDI registries and only trust company can
register the service.
• Real business will used private UDDI registry
to find the service.
Web Service
Service
Registry
1. Service provider
Publish Service
2. Service requestor
find the service
SOAP on HTTP
Service
Requestor
Service
provider
3. Use the service
through a SOAP call
(use WSDL to build the
SOAP request)
J2EE vs. .Net
To develop web service:
java:
Platform > JVM > servlet, jsp, jdbc, jndi, jms, rmi, corba,
EJB, jax package etc.
.net
Wintel > CLR (common Language Runtime) >
System.WebService, ASP.NET, DirectoryServices,
System.Messaging, System.Runtime.Remoting, MSXML,
SOAP, WSDL etc.
Tools available
Tools for Java & Web Service
•
•
•
•
SOAP4J (apache & IBM), JAX package (sun)
GLUE (the mind electric)
Sun: bowstreet (include Jbuilder)
IBM websphere (include Application developer IDE)
Utility tools
• Tcp monitor/tunnel (Soap4J) (to monitor soap message)
• Struts(apache) (to generate web interface from WSDL file)
Sun ONE (Open Net Environment)
SOAP4J (apache)
• Client library to invoke SOAP service
- API for invoking SOAP RPC service
- API for sending and receiving SOAP
messages.
• Used as a server – side tool to
implement SOAP accessible services.
- RPC accessible service
- Message accessible service
JAX package – Java API for XML
•
•
•
•
JAXP – parse XML documents
JAXB – map XML elements to java classes
JAXM – sends SOAP messages
JAXR –provides a standard way to access
business registry
• JAX-RPC – sends SOAP calls to remote
parties
• MultiSchema Validation – not in JAX package
IBM/Apache Struts
Struts
Controller
Servlet
WSDL
Struts
Controller
Servlet
WSDL Parser
Action
Input Form
JSP
SOAP
SOAP call
Action
Output Form
JSP
GLUE
to create software building blocks that are
language, platform and location independent.
Useful feature:
• A toolkit for parsing and manipulating XML
• XML/Java mapping system
• XML storage system
• SSL authentication
• A browser-based management console
Glue - Demo
public class Exchange {
public float getRate( String country1, String country2 ) {
return 122.69F; // always return a constant for this demo
}
}
import electric.registry.Registry;
import electric.server.http.HTTP;
public class Publish1 {
public static void main( String[] args ) throws Exception {
// start a web server on port 8004, accept messages via /glue
HTTP.startup( "http://localhost:8004/glue" );
// publish an instance of Exchange
Registry.publish( "urn:exchange", new Exchange() );
}
}
>java Publish1
GLUE 1.2 © 2001 The Mind Electric
Startup server on http://129.57.41.138:8004/glue
Glue - Demo
http://einstein.jlab.org:8004/glue/urn:exchange.wsdl
Glue - Demo
import electric.registry.Registry;
import examples.publish.IExchange;
public class Invoke1{
public static void main( String[] args ) throws Exception {
// bind to web service whose WSDL is at the specified URL
String url = "http://localhost:8004/glue/urn:exchange.wsdl";
Exchange exchange = (Exchange) Registry.bind( url, Exchange.class );
// invoke the web service as if it was a local java object
float rate = exchange.getRate( "usa", "japan" );
System.out.println( "usa/japan exchange rate = " + rate );
}
}
> java Invoke1
usa/japan exchange rate = 122.69
Glue - Demo
http://einstein.jlab.org:8080/console/index.esp
WSDL = http://einstein.jlab.org:8004/glue/urn:exchange.wsdl
IBM WebSphere Studio
• WebSphere Stuio Site Developer – a tool for
developing and managing web sites that include
HTML, JSP pages, Java servlets, rich media, xml,
and web services.
• WebSphere Stuio Application Developer – a
J2EE-compliant server-side Java tool, focusing on
EJB development, deployment, and profiling, that
also contains all the functionally of Site Developer.
IBM Application Developer
•
•
•
•
•
•
•
•
•
•
EJB and servlet creation and deployment
Performance profiling and analysis tools
Database wizards
Web services wizards
JSP tags
Team environment
XML tools
Core Java IDE
Web page wizards with dynamic effects
Java development environment
Web service development
• Discover – browse the UDDI registry to locate existing Web
services for integration
• Create or transform – create Web service from existing
projects.
• Build – wrap existing artifacts as SOAP and HTTP service and
describe them in WSDL.
• Deploy – deploy the Web service into Websphere Application
server or Tomcat.
• Test – test the web service as it runs locally or remotely
• Develop – generate a sample application to assist you in creating
your own Web service client application.
• Publish – publish Web service to the UDDI business registry.
XML tools
•
•
•
•
Create, view, and validate DTDs and XML schemas
Create XML documents from DTD
Generate JavaBeans from DTD or xml schema
Define mappings between XML documents and
generate XSLT scripts that transform documents.
• XSL stylesheet processor (xalan)
Sun - bowstreet
BowStreet - Business Web Portal Solution
• Portal Configuration & Customization
- Create portals within minutes using wizards.
- Build in portal “factory”
• Application Integration
-
Packaged application
Content & document management
Application servers
Messaging systems
XML, EJB, SOAP etc.
Summary
JAX package - use it in grid project to send soap
message
Apache SOAP4J - slow, include server and client.
GLUE – use it to generate WSDL and web console.
Sun: bowstreet (include Jbuilder)
- no experience
IBM Websphere
- only got complimentary preview copy
- contains too much (most are not needed)
Jbuilder – Good IDE for java development
JLab Grid Web Service
Service:
• Convert the GridServer (application) to a bean-like
application.
• Modify GridService (servlet) to take SOAP request
using jaxm package (or other).
• Add WSDL to describe our service (use GLUE or
other package to generate it).
Client:
• Add Soap layer for requesting the service.
• Create service web interface (html) using GLUE or
Struts package.