You are on page 1of 53

Move on to WSDL 2.

0 and Apache
Woden

Sagara Gunathunga
Apache Committer

Who am I ?
Apache Woden Committer
Also contribute to Apache Axis2 and
Apache Camel .

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

What is a contract in real world ?

Contract in Web services


WHAT ?

HOW ?

WHERE ?

WHAT it does ?
Define the purpose and function of its operations.
Define the messages that need to be exchanged in
order to engage the operations.
Define data models used to define the structure of the
messages.
Define a set of conditions under which the operations
are provided.
Define information about how and where the service
can be accessed.

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

Todays SDLs
WSDL 1.1 ( Web Service Description Language 1.1)
WADL ( Web Application Description Language)
SSDL (SOAP Service Description Language)

WSDL 1.1
WSDL is an XML-based language used to define
Web Services and describe how to access them.
WSDL is an XML format for describing network services as
a set of endpoints operating on messages containing either
document-oriented or procedure-oriented style.
WSDL 1.0 was Jointly developed by IBM, Microsoft and
many others in 2000.
WSDL 1.1 released in 2001.
Compliant with WSDL Basic profile 1.0

WSDL 1.1

Pros
Proven and Widely used in industry for last few years.
Compliant with WS-I basic profile 1.0
Many projects available - WSDL4J , WOM
Code generation tools available
Axis2 /CXF WSDL2Java ,wsimport
Cons
Really complex language.
Hard learning curve.
Not fit with REST services.

WADL
WADL is a description language for HTTP-based Web
applications, such as applications which follow the
REST architectural style.

Written by Marc Hadley at Sun somewhere around


2006.
From August 2009 WADL is a W3C Member
Submission.

Pros
Works well with REST services.
Automation tools available WADL2JAVA , Google REST compiler
Some projects available

- Jersey

Cons
Still not widely used as WSDL 1.1
Doesn't support for SOAP based web services.

SSDL
The SOAP Service Description Language (SSDL) is a
SOAP-centric contract description language for Web
Services

Pros
Works well with SOAP based web services.
Project available - Soya for C#
Cons
Not widely used in neither industry nor academic purposes.
Only support for SOAP.
No automation tools available .
No project for java.

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
Introduction to Apache Woden
WSDL 2.0 and REST
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

WSDL 2.0
Improved version of WSDL 1.1
Simple and no ambiguities unlike WSDL 1.1 and easy
learning curve.
Fully supports for both SOAP based and RESTful web
services.
Removal of message constructs. These are specified
using the XML schema type system.

Possibility to define QoS features and properties

WSDL 2.0
Well defined Message Exchange Patterns (MEP)
Some WS engines already supports and provide
automation tools
- Axis2 and WSDL2Java

Wsdl1.1/2.0 Comparison
WSDL 1.1

WSDL 2.0

<definition>

<description>

<portType>

<interface>

<binding>

<binding>

<types>

<types>

<service>

<service>

<port>

<endpoint>

<message>

Within <operation>

WSDL 2.0 component model

Description is container for 2 types of top-level components.


(1) WSDL Component (interface , binding , services)
(2) Type system component
(ElementDeclaration,typeDefinition)

WSDL 2.0 nested component


model

Feature & property


Provides additional processing information for a component
example reliability , correlation

MEP Message Exchange


patterns
MEP defines a contract between service and client
WSDL 2.0 defines 8 MEPs

In-Only
Robust In-Only
In-Out
In-Optional-Out
Out-Only
Robust Out-Only
Out-In
Out-Optional-In

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

WSDL 2.0 and REST


The "WSDL 2.0 Part 2: Adjuncts" provides the specifics of
HTTP, SOAP 1.2, and MEP usage with WSDL 2.0. WSDL
2.0 HTTP Binding can be used to define REST services
successfully.
Following HTTP methods can be used.
7. GET
8. POST
9. PUT
10.DELETE

WSDL 2.0/ HTTP Binding


Binding type should be http://www.w3.org/2006/01/wsdl/http
<binding
name="xs:NCName"
interface="xs:QName"?

type="http://www.w3.org/ns/wsdl/http"
whttp:methodDefault="xs:string"?
whttp:queryParameterSeparator
Default="xs:string"?
whttp:cookies="xs:boolean"?
whttp:contentEncodingDefault="xs:string"? >

WSDL 2.0/ HTTP Binding


<operation ref="xs:QName"
whttp:location="xs:anyURI"?
whttp:method="xs:string"?
whttp:inputSerialization="xs:string"?
whttp:outputSerialization="xs:string"?
whttp:faultSerialization="xs:string"?
whttp:queryParameterSeparator="xs:string"?
whttp:contentEncodingDefault="xs:string"?
whttp:ignoreUncited="xs:boolean"? >
In most cases location and method attributes are
sufficient .

Example
<wsdl2:binding name="DemoServiceHttpBinding"
interface="tns:DemoServiceInterface"
type=http://www.w3.org/ns/wsdl/http >
<wsdl2:operation
ref="tns:demo"
whttp:method="POST"
whttp:location="demo />
</wsdl2:binding>

Input and Output Serialization


Formats
Input format

Output format -

{http input serialization}


{http output serialization}

HTTP Method

Default Input
Serialization

Default Output
Serialization

GET

application/x-wwwform-urlencoded

application/xml

POST

application/xml

application/xml

PUT

application/xml

application/xml

DELETE

application/x-wwwform-urlencoded

application/xml

Example

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

Apache Woden

Apache Web Services Project to develop a


Java class library for reading, manipulating,
creating and writing WSDL documents, initially
to support WSDL 2.0 but with the longer term
aim of supporting past, present and future
versions of WSDL.
Who uses Woden
- Apache Axis2
- Apache ServiceMix

Main deliverables
1.

Woden API for WSDL 2.0

2.

DOM based implementation.

3.

OM (Axiom) based implementation.

4.

WSDL 2.0 validator tool

5.

WSDL1.1 to 2.0 Converter tool.

6.

Maven plug-ins and Ant Tasks for above tools

Two APIs
Component model API
Mirror the component model of WSDL 2.0
One root Description object representing a merge of all
.wsdl files imported and included

Element level API


Mirror the XML representation of WSDL 2.0
Represent the physical Xml file representation

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

Component level Element


level
To Component model
aElement.toComponent()

To Element model
aComponent.toElement()

Example
DescriptionElement descElement;
Description descComponent;
descComponent=descElement.toComponent();
descElement=descComponent.toElement();

Define the implementation


DOM or OM
Using WSDLFactory you can specify the implementation.
Default implementation is based on DOM
For DOM implementation
WSDLFactory FWSDLFactory=WSDLFactory.newInstance();

OR
WSDLFactory FWSDLFactory=
WSDLFactory.newInstance(org.apache.woden.internal.DOMWSDLFactory);

For OM implementation
WSDLFactory FWSDLFactory=
WSDLFactory.newInstance(org.apache.woden.internal.OMWSDLFactory);

Reading WSDL 2.0 documents


// create WSDL factory instance.

WSDLFactory FWSDLFactory=WSDLFactory.newInstance();
//create WSDL reader instance

WSDLReader reader=FWSDLFactory.newWSDLReader();
//set validation

reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
//read the WSDL file in to a DescriptionElement

DescriptionElement descElem = reader.readWSDL(wsdlurl);

Writing WSDL 2.0 document


// create WSDL factory instance.

WSDLFactory FWSDLFactory=WSDLFactory.newInstance();
//create WSDL writer instance

WSDLWriter writer=FWSDLFactory.newWSDLWriter()
//Write WSDL in to the console

writer.writeWSDL(descElem, System.out )
//write WSDL as a file

writer.writeWSDL(descElem, new FileOutputStream("test.wsdl") )

create WSDL document


At the moment only support for Element level API
WSDLFactory wsdlFactory=WSDLFactory.newInstance();
DescriptionElement descElement=wsdlFactory.newDescription();
descElement.setTargetNamespace(new URI("http://my.com") );
InterfaceElement interElement=descElement.addInterfaceElement();
InterfaceOperationElement
iOpElement=interElement.addInterfaceOperationElement();
BindingElement bindingElement=descElement.addBindingElement();
BindingOperationElement
bOpElement=bindingElement.addBindingOperationElement();

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

Woden tools - validation


Schema validations done by the XML parsers.
Semantic validations done by Woden validator.
- on the WSDL object model assertions are checked
against the model.
All errors are reported in one pass. Woden does not
stop-on-first-error like WSDL4J.

Woden tools - Validation


Validation is off by default.
Enable validation before reading the WSDL

Example
reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);

Woden tools - WSDL Converter


Perform WSDL 1.1 to 2.0 conversion.
Another great feature.
Based on XSLT style sheet.
Available as a Standalone tool, as a Maven plug-in or an
Ant Task

Woden tools - WSDL Converter


In command line
java -Djava.ext.dirs=/home/sagara/woden
org.apache.woden.tool.converter.Convert
-wsdl /home/sagara/test/converter/Echo.wsdl
programmatically
Convert convert = new Convert();
try {
convertFile =
convert.convertFile(newTargetNS,wsdlDoc,
targetDir,verbose,overwrite);
System.out.println(convertFile);
} catch (Exception e) {
e.printStackTrace();
}

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

What is new in Woden 0.9


Woden Serialization - WSDLWriter based on DOM and
OM.
Split QName into a different package to resolve conflicts in
OSGI environments.
Remove dependency on Xereces , now Woden(dom) work
with any JAXP implementation
Component level equals method.
Logging framework based on Commons-logging API.
WSDL Converter Maven plug-in and Ant Task
Code base refactored for more Maven friendly manner .

Outline

Introduction to SDLs
Todays SDLs
Introduction to WSDL 2.0
WSDL 2.0 and REST
Introduction to Apache Woden
Hands-on Apache Woden
Apache Woden tools
What is new in Apache Woden 0.9
WSDL 2.0 based WS development in Axis2

WSDL 2.0 based WS development


in Axis2
Axs2 supports for WSDL 2.0
1.) Contract first Web services.
2.) Code first services

WSDL 2.0 based WS development


in Axis2
In Contract first WS development you can use Axis2
WSDL2JAVA tool to generate source codes from your
WSDL 2.0 documents.
Both WSDL2JAVA Ant Task and Maven Plug-in supports
for WSDL 2.0
In WSDL2JAVA Command line tool use -wv 2 or -wv 2.0
options. With Maven Plug-in use wsdlVersion option.
Example :
wsdl2java -wv 2

OR

wsdl2java -wv 2 .0

WSDL 2.0 based WS development


in Axis2
In code first approach, to generate WSDL 2.0 document
use ?wsdl2 instead of ?wsdl .
Example :

http://localhost:8080/services/SimpleService?wsdl2

Contribution
Site : http://ws.apache.org/woden/
Mailing list : woden-dev@ws.apache.org

Thank You

You might also like