Download Tecnologie per servizi web: WSDL, WSFL & co.

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Models and Languages for Coordination and Orchestration
IMT- Institutions Markets Technologies - Alti Studi Lucca
WS Technologies II
API
Roberto Bruni
Dipartimento di Informatica
Università di Pisa
1
Roberto Bruni @
IMT Lucca
16 March 2005
SOAP
HELP!
SOAP
UDDI
UDDI
SOAP
SOAP
UDDI
SOAP
UDDI
UDDI
SOAP
SOAP
SOAP
UDDI
UDDI
SOAP
UDDI
SOAP
SOAP
Institutions
SOAP
Markets
Technologies
IMT
UDDI
SOAP
Models and Languages for
Coordination andUDDI
Orchestration
UDDI
SOAP
2
Roberto Bruni @
IMT Lucca
16 March 2005
Contents


WSDL
Some Java tools
Institutions
Markets
Technologies
IMT
Models and Languages for
Coordination and Orchestration
3
Roberto Bruni @
IMT Lucca
16 March 2005
API and Tools


Quick overview of some helpful tools that you
may want to use
Skipping all technical details, we will see




some reference sites
main features of widespread tools
few simple examples
For up-to-date tools check periodically the web
pages of W3C, Apache, IBM, Sun, Microsoft, …
Institutions
Markets
Technologies
IMT
Models and Languages for
Coordination and Orchestration
4
Roberto Bruni @
IMT Lucca
16 March 2005
Java and XML

Very often Web Services developers have to
manipulate XML documents and archives

manual editing is extremely complicated



can easily lead to errors and inconsistencies
even if supported by visual integrated environments
For automating most frequent operations, Sun has
developed and released a whole set of tools

Java Web Services Developer Pack (v1.5)


Institutions
Markets
Technologies
http://java.sun.com/webservices/downloads/webservicespack.html
essentially: Java APIs for manipulating XML files
IMT
Models and Languages for
Coordination and Orchestration
5
Roberto Bruni @
IMT Lucca
16 March 2005

Advantages





Java API for XML Processing
(JAXP) – Parser SAX
Can be used to analyze efficiently XML documents of
any dimension
useful to build ad hoc data structures
useful for extracting information
fast processing
Disadvantages



Institutions
Markets
Technologies
IMT
sequential access to the document
complex searches are hard to implement
can be used just for reading the document
Models and Languages for
Coordination and Orchestration
6
Roberto Bruni @
IMT Lucca
16 March 2005

Advantages





Java API for XML Processing
(JAXP) – Parser DOM
builds a tree-like representation of the document
useful to elaborate the data
facilitate document modification
random access
Disadvantages

Institutions
Markets
Technologies
IMT
bad memory usage
Models and Languages for
Coordination and Orchestration
7
Roberto Bruni @
IMT Lucca
16 March 2005


Java API for XML Binding
(JAXB)
Provides a bi-directional method for binding XML
documents and Java objects
Starting from a


DTD
and a binding schema (suffix .xjs)


coding establishing variable types and the mechanism for
defining the classes
generates a set of classes that can be used to
read, write and modify valid XML document (w.r.t.
the given DTD)
Institutions
Markets
Technologies
IMT
Models and Languages for
Coordination and Orchestration
8
Roberto Bruni @
IMT Lucca
16 March 2005
JAXB Terminology

Marshalling

serialization of the Java object representing the XML
document


Unmarshalling


ex. can be used to write the document in the file system
builds a Java object starting from an XML source
Validation

Institutions
Markets
Technologies
IMT
can be used to check if an XML document conforms a
DTD (represented as a JAXB object)
Models and Languages for
Coordination and Orchestration
9
Roberto Bruni @
IMT Lucca
16 March 2005
Example JAXB I
<!-- books.dtd -->
<!ELEMENT books (book*) >
<!ELEMENT book
(title, author, price) >
<!ATTLIST book category CDATA #REQUIRED >
<!ELEMENT title (#PCDATA) >
<!ELEMENT author (#PCDATA) >
<!ELEMENT price (#PCDATA) >
Institutions
Markets
Technologies
IMT
In its simplest form
the XJS file has
just the definition
of the root element
<!-- books.xjs -->
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xml-java-binding-schema version="1.0ea">
<element name="books" type="class" root="true" />
</xml-java-binding-schema>
Models and Languages for
Coordination and Orchestration
10
Roberto Bruni @
IMT Lucca
16 March 2005
Example JAXB II

The execution of jaxb-xjc originates two files

Books.java



contains the java.util.List of the instances of Book
Book.java
Both classes come equipped with methods




Institutions
Markets
Technologies
IMT
for marshalling
for unmarshalling
for validation
plus equals(), toString(), getX(), setX(), …
Models and Languages for
Coordination and Orchestration
11
Roberto Bruni @
IMT Lucca
16 March 2005

Java API for XML Messaging
(JAXM)
JAXM provides a suitable abstraction for the SOAP
messaging infrastructure


only messages in SOAP format are supported
no transport mechanism is imposed





provides the interfaces for the composition and analysis of SOAP
messages
supports synchronous and asynchronous communication
DOES NOT attempt to define a more abstract level on top of SOAP
for guaranteeing reliability or other properties
DOES NOT provide high level functionalities for publication,
discovery and use of services

Institutions
Markets
Technologies
IMT
HTTP, SMTP, MOM (Message Oriented Middleware)
they are UDDI and WSDL concern (not SOAP ones)
Models and Languages for
Coordination and Orchestration
12
Roberto Bruni @
IMT Lucca
16 March 2005

Java API for XML-based RPC
(JAX-RPC)
It is JAX-RPC, not JAX-SOAP




API for RPC based on XML
focuses on supporting RPC
not just limited to SOAP implementation of RPC
DOES NOT support all SOAP functionalities


define a standard Java mapping for SOAP


Institutions
Markets
Technologies
IMT
limited support for messaging
(names and types conversion)
does its best for hiding the XML coding
Models and Languages for
Coordination and Orchestration
13
Roberto Bruni @
IMT Lucca
16 March 2005
Java and WSDL


Manual editing of WSDL documents for your Java
classes is probably a boring task that you may
want to avoid
I guess you would like some tools for automatic
generation of WSDL documents


(or at least semi-automatic)
The good news is that you can move from Java to
WSDL and back
Institutions
Markets
Technologies
IMT
Models and Languages for
Coordination and Orchestration
14
Roberto Bruni @
IMT Lucca
16 March 2005
Java2WSDL

Axis (http://ws.apache.org/axis/index.html) offers
the possibility of generating the WSDL file in an
automatic way starting from the Java class file

Example
/* HelloWorldWSDL.java */
package sams;
public class HelloWorldWSDL {
public String helloWorld() {
return “Hello World!”;
}
}
Institutions
Markets
Technologies
IMT
abstract definition
• HelloWorldWSDL.wsdl
implementation
• HelloWorldWSDL-impl.wsdl
Models and Languages for
Coordination and Orchestration
15
Roberto Bruni @
IMT Lucca
16 March 2005
WSDL2Java

On the other way round, for interacting with a Web Service
as users, you must be able to read the corresponding WSDL
document and produce the correct code (ex. in Java)



again, manual processing would be tedious and time consuming
Java2WSDL has a "sister" that can help us
example: from HelloWorldWSDL.wsdl we get



Note that:


Institutions
Markets
Technologies
IMT
HelloWorldWSDLSoapBindingStub.java
HelloWorldWSDLPortType.java
HelloWorldWSDLPortType represents a remote object
HelloWorldWSDLSoapBindingStub contains all implementation details
that are necessary for the transfer of SOAP messages toward the server
Models and Languages for
Coordination and Orchestration
16
Roberto Bruni @
IMT Lucca
16 March 2005
More Technologies

UDDI4J



WSDL4J (WS Desciption Language for Java Toolkit)



http://www-124.ibm.com/developerworks/oss/uddi4j/
Java API for interacting with UDDI registries
http://www-124.ibm.com/developerworks/projects/wsdl4j/
supports the creation, representation and manipulation of WSDL
documents
SAAJ (SOAP with Attachment API for Java)



Institutions
Markets
Technologies
IMT
http://java.sun.com/xml/saaj/index.jsp
component of JWSD Pack
define a standard for sending XML documents with attachments from
a Java platform to the Internet
Models and Languages for
Coordination and Orchestration
17