wsdl:types - Fakulta matematiky, fyziky a informatiky

clappingknaveΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

82 εμφανίσεις

Agenda


SOAP


WSDL & XML Schema


XSLT & XPath


Sonic ESB

SOAP


flexible protocol for
transfer of XML messages

between
applications


application
A

(initial SOAP sender) sends message to
application
Z

(ultimate SOAP receiver); message can go through
applications
B, C, D, ...

(SOAP intermediaries) on the way



independent of transport protocol


usually HTTP(S), can be JMS, SMTP, ...



message = header + body

SOAP (2)


the header
is typically used for control information for
“advanced” services such as


security (authentication, integrity, confidentiality)


transactions


reliable delivery


addressing


...


consists of
header blocks


generalized form of well
-
known headers of HTTP, RFC 822, ...


standard attributes: role, mustUnderstand, relay


not defined by SOAP as such, but by various WS
-
* specs



the body

is
application
-
specific

(except for faults)

XML Namespaces


names of elements and attributes can be
globally unique
,
if there

is
a
namespace

specified for them



examples
:


<
cat:PriceList
xmlns:cat=
“http://
warehouse
.sk/
catalogue

>


<
cat:Item
> ...


<
PriceList
xmlns=
“http://
warehouse
.sk/
catalogue

>


<
Item
> ...



<
env:Envelope


xmlns:env="http://www.w3.org/2003/05/soap
-
envelope"
>













<
env:Body
>


<
obj
ednavka

xmlns="http://obchod.sk/schemy"
>


<
predmet
>
matice M8
</predmet> <
mno
zstvo
>
20 kg
</mno
zstvo
>


</obj
ednavka
>


</env:Body
>

<
/env:Envelope
>

<
env:Envelope


xmlns:env="http://www.w3.org/2003/05/soap
-
envelope"
>



<
env:Header
>


<
wsse:Security

env:
mustUnderstand="true"

xmlns:wsse=...
>


<
wsse:UsernameToken
>


<
wsse:Username
>
peter
</wsse:Username
>


<
wsse:Password
>
secret
!
</wsse:Password
>


</wsse:UsernameToken>


</wsse:Security
>


...


<
/env:Header
>



<
env:Body
>


<
obj
ednavka

xmlns="http://obchod.sk/schemy"
>


<
predmet
>
matice M8
</predmet> <
mno
zstvo
>
20 kg
</mno
zstvo
>


</obj
ednavka
>


</env:Body
>

<
/env:Envelope
>

SOAP (3)
-

an example

tags defined by SOAP

tags defined by WS
-
Security

tags defined by
the
application

SOAP (4)


our case

<?xml version="1.0" encoding="UTF
-
8"?>

<SOAP
-
ENV:Envelope
xmlns:SOAP
-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
>


<SOAP
-
ENV:Body>


<tns:ID xmlns:tns="http://xml.uniba.sk/is/customer">
123456
</tns:ID>


</SOAP
-
ENV:Body>

</SOAP
-
ENV:Envelope>


SOAP (5)


message exchange can be


synchronous

(
e.g.
request

and
reply in one HTTP session)


asynchronous

(
e.g.
request

and
reply as separate HTTP
sessions)


one
-
way


...


Properties


platform neutral, generally accepted


rich programming support


though compatibility is not 100%
(
as of today
)


extensible


though more advanced specifications are not so widespread as
the basic protocol


human
-
friendly

(sometimes)


due to the use of XML


performance issues


though alternative XML encodings are emerging

WSDL & XML Schema

<?xml version=“1.0” encoding=“UTF
-
8”?>

<Order>


<OrderID>
10200341
</OrderID>


<Customer>


<CustomerID>100347</CustomerID>


</Customer>


<TotalPrice currency=“
SKK
”>
3400
</TotalPrice>


<Items>


<Item>


<ProductID>
491
</ProductID>


<Quantity>
100
</Quantity>


<UnitPrice currency=“
SKK
”>
34
</UnitPrice>


</Item>



...


</Items>


<Shipping>


<ShipTo>
Astronomicko
-
geofyzik
álne observatórium,


920 01 Modra
</ShipTo>


</Shipping>

</Order>

An Order

Service 1: GetCustomerDetails

Input:

HTTP POST to
http://localhost/hello


<?xml version=“1.0” encoding=“UTF
-
8”?>

<GetCustomerDetails>


<ID>
100347
</ID>

</GetCustomerDetails>


Output:

HTTP data returned


<?xml version=“1.0” encoding=“UTF
-
8”?>

<GetCustomerDetailsReply>


<ID>
100347
</ID>


<Type>
CORP
</Type>


<Level>
GOLD
</Level>


<Name>
Fakulta matematiky, fyziky a informatiky UK
</Name>


<Address>
Mlyn
ská dolina, 84248 Bratislava
</Address>


<
Status
>
OK
</Status>

</GetCustomerDetailsReply>

CustomerService

operation: GetCustomer
Details

Input:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<c:ID xmlns:c=“http://xml.uniba.sk/is/customer”>
100347
</c:ID>


Output:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<c:CustomerInformation xmlns:c=“http://xml.uniba.sk/is/customer”>


<c:ID>
100347
</c:ID>


<c:Type>
CORP
</c:Type>


<c:Level>
GOLD
</c:Level>


<c:Name>
Fakulta matematiky, fyziky a informatiky UK
</c:Name>


<c:Address>
Mlyn
ská dolina, 84248 Bratislava
</c:Address>


<c:
Status
>
OK
</c:Status>

</c:CustomerInformation>

WSDL


Web Services Description Language


describes
format of messages
received and sent
by the service


at
abstract level
(messages, operations, port types)


at
concrete level

(bindings, ports, services)



optionally specifies also
policies


e.g. “this service requires authentication done by WS
-
Security, specifically X.509 certificates”


specified in WS
-
PolicyAttachment


WSDL: abstract description


interface

(port type) consists of
operations



operation

consists of
messages


input, [output], [fault(s)]



message

consists of
parts



part
is specified as
an element
or
a type
in XML
Schema

<wsdl:definitions ...>


<wsdl:types>


<xsd:schema ...>


<xsd:element name="
A
" type="xsd:integer"/>


<xsd:element name="
B
" type="xsd:integer"/>


<xsd:element name="
C
" type="xsd:integer"/>


</xsd:schema>


</wsdl:types>



<wsdl:message name="
Input
">


<wsdl:part name="
A
" element="
tns:A
"/>


<wsdl:part name="
B
" element="
tns:B
"/>


</wsdl:message>


<wsdl:message name="
Output
">


<wsdl:part name="
C
" element="
tns:C
"/>


</wsdl:message>



<wsdl:portType name="
CalculatorInterface
">


<wsdl:operation name="
Sum
">


<wsdl:input message="
tns:Input
“/>


<wsdl:output message="
tns:Output
“/>


</wsdl:operation>


</wsdl:portType>

CustomerService

operation: GetCustomerInformation

Input:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<
c:ID

xmlns:c=“http://xml.uniba.sk/is/customer”>
100347
</c:ID>


Output:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<
c:CustomerInformation

xmlns:c=“http://xml.uniba.sk/is/customer”>


<c:ID>
100347
</c:ID>


<c:Type>
CORP
</c:Type>


<c:Level>
GOLD
</c:Level>


<c:Name>
Fakulta matematiky, fyziky a informatiky UK
</c:Name>


<c:Address>
Mlyn
ská dolina, 84248 Bratislava
</c:Address>


<c:
Status
>
OK
</c:Status>

</c:CustomerInformation>

<wsdl:definitions ...>



<wsdl:types>

...

<
/wsdl:types>



<wsdl:message name=“
GCDRequest
">


<wsdl:part name=“
DefaultInput
" element="
c:ID
"/>


</wsdl:message>


<wsdl:message name=“
GCDResponse
">


<wsdl:part name=“
DefaultOutput



element="
c:CustomerInformation
"/>


</wsdl:message>



<wsdl:portType name=“
CustomerServicePortType
">


<wsdl:operation name="
GetCustomerDetails
">


<wsdl:input message="
tns:GCDRequest
"/>


<wsdl:output message="
tns:GCDResponse
"/>


</wsdl:operation>


</wsdl:portType>

XML Schema


schema



a document that describes a set of compliant
XML documents (
instances

of this schema)


describes

elements
and their
attributes

(using
types
)


types are
:


simple
(
attributes and text
-
only elements
)


complex

(
elements with subelements and/or attributes
)


simple types
:


predefined


derived

(
e.g. by restriction
)


complex types are defined by
:


attributes and/or subelements
(
list, cardinality, default values, ...
)


extension

(

inheritance
)


...

XML Schema

(2)


simple types examples


string, normalizedString, token


base64Binary


hexBinary


integer


[non]positiveInteger


[non]negativeInteger


[unsigned][long|int|short|byte]


decimal, float, double


boolean


dateTime, date, time


duration



gYear, gYearMonth, gMonth,
gMonthDay, gDay


Name


QName


NCName


anyURI


language


ID, IDREF,

IDREFS, ENTITY,
ENTITIES, NOTATION,
NMTOKEN, NMTOKENS

<wsdl:types>




<xsd:schema elementFormDefault="qualified"


targetNamespace="
http://xml.uniba.sk/is/customer
"


xmlns:xsd="http://www.w3.org/2001/XMLSchema">



<xsd:element name="
ID
" type="
xsd:string
"/>



<xsd:element name="
CustomerInformation
">


<xsd:complexType>



<xsd:sequence>



<
xsd:element name="
ID
" type="
xsd:string
"/>



<xsd:element name="
Type
" type="
xsd:string
"/>



<xsd:element name="
Level
" type="
xsd:string
"/>



<xsd:element name="
Name
" type="
xsd:string
"/>



<xsd:element name="
Address
" type="
xsd:string
"/>



<xsd:element name="
Status
" type="
xsd:string
"/>



</xsd:sequence>


</xsd:complexType>


</xsd:element>


</xsd:schema>


</wsdl:types>

Input:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<
c:ID

xmlns:c=“http://xml.uniba.sk/is/customer”>
100347
</c:ID>


Output:


<?xml version=“1.0” encoding=“UTF
-
8”?>

<
c:CustomerInformation

xmlns:c=“http://xml.uniba.sk/is/customer”>


<c:ID>
100347
</c:ID>


<c:Type>
CORP
</c:Type>


<c:Level>
GOLD
</c:Level>


<c:Name>
Fakulta matematiky, fyziky a informatiky UK
</c:Name>


<c:Address>
Mlyn
ská dolina, 84248 Bratislava
</c:Address>


<c:
Status
>
OK
</c:Status>

</c:CustomerInformation>

WSDL: concrete description


binding


specifies
concrete protocol
(SOAP 1.1, HTTP, MIME)


specifies details, e.g. for SOAP 1.1:


how parts are mapped to SOAP Headers and/or
SOAP Body


value(s) for soapAction


call style:
document

or

rpc


encoding:
literal

or
encoded


transport (e.g. HTTP, SMTP, JMS)


service


subelements
port
that specify physical addresses
(e.g. URLs) at which individual bindings are reachable


<wsdl:binding name="SOAPBinding“


type="
tns:CustomerServicePortType
">


<soap:binding style="
document



transport="http://schemas.xmlsoap.org/soap/http"/>


<wsdl:operation name="
GetCustomerDeteails
">


<soap:operation
soapAction="
http://xml.uniba.sk/is/customer/CustomerServicePortType/GetCustomerDe
tailsRequest
"
/>


<wsdl:input>


<soap:body use="literal"/>


</wsdl:input>


<wsdl:output>


<soap:body use="literal"/>


</wsdl:output>


</wsdl:operation>


</wsdl:binding>


<wsdl:service name="
CustomerService
">


<wsdl:port name=“
CustomerServicePort



binding="
tns:SOAPBinding
">


<soap:address


location="
http://localhost:2580/process/CustomerService
"/>


</wsdl:port>


</wsdl:service>

</wsdl:definitions>

XSLT, XPath

XSLT


part of XSL (Extensible Stylesheet Language)


includes also XPath and XSL Formatting Objects


used to transform an XML document into:


another XML document (or a part of it)


HTML document


or any other text document (although not designed to
do so)



An XSLT processor

takes an
XSLT stylesheet

to
convert
an

input document

into
the output
document

XSLT stylesheet


consists of
template rules
(xsl:template elements)



each rule describes:


a
pattern

to match (e.g. element name)


set of
parameters

(optionally)


a sequence constructor
: data (template) to output,
typically


some markup


some data copied from source document


some new data


<?xml version="1.0"?>

<
ListOfStudents
>




<?xml version="1.0"?>

<
Students
>


<
Person

id
="
12998800
">


<
FirstName
>
Peter
</
FirstName
>


<
LastName
>
Kov
áč
</
LastName
>


<
BirthDate
>
1980
-
10
-
25
</
BirthDate
>


<
Study
>


<
Program

id
="
1.MAT
"></
Program
>


<
Faculty

id
="
1070
">
FMFI UK
</
Faculty
>


</
Study
>


<
Study
>


<
Program

id="
1.AE
"></
Program
>


<
Faculty

id="
1050
">
FiF UK
</
Faculty
>


</
Study
>


</
Person
>


<
Person

id
="
88332212
">


<
FirstName
>
Karol
</
FirstName
>


<
LastName
>
Nový
</
LastName
>


<
BirthDate
>
1982
-
11
-
16
</
BirthDate
>


<
Study
>


<
Program id
="
1.INF
"></
Program
>


<
Faculty id
="
1070
">
FMFI UK
</
Faculty
>


</
Study
>


</
Person
>

</
Students
>

<?xml version="1.0"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/
XSL/Transform">



<xsl:template match="
/
">


<
ListOfStudents
>


<xsl:apply
-
templates/>


<
/ListOfStudents
>


</xsl:template>



<xsl:template match="
Person
">


<Student>


<xsl:value
-
of


select="
FirstName
"/>
,


<xsl:value
-
of


select="
LastName
"/>
,


<xsl:value
-
of


select="
Study
[1]/
Faculty
"/>


(
<xsl:value
-
of


select="
Study
[1]/
Faculty
/@
id
"/>
)


</Student>


</xsl:template>

</xsl:stylesheet>

<?xml version="1.0"?>

<
ListOfStudents
>


<
Student
>Peter,
Kováč
, FMFI UK (1070)</
Student
>


<
Student
>Karol, Nový, FMFI UK (1070)</
Student
>

</
ListOfStudents
>

<xsl:template match="
c:ID
"
xmlns:c="http://xml.uniba.sk/is/customer">


<GetCustomerDetails>


<ID>


<xsl:value
-
of select="."/>


</ID>


</GetCustomerDetails>

</xsl:template>

<?xml version="1.0" encoding="UTF
-
8"?>

<tns:ID xmlns:tns="http://xml.uniba.sk/is/customer">123456</tns:ID>


<?xml version=“1.0” encoding=“UTF
-
8”?>

<GetCustomerDetails>


<ID>100347</ID>

</GetCustomerDetails>

Documents


modeled as
trees

with following kinds of nodes:


the root (/)


element


attribute


text


namespace


processing instruction


comment


Basic algorithm


XSLT processor accepts an
input tree
and produces an
output tree



Transformation is done by
evaluating the sequence
constructor

of the
initial template
.


initial template: if not set explicitly, it is template rule selected for
processing
initial context node

(default: root node)


other templates can be “called” from here



Default templates:


for elements: call apply
-
templates on all child elements


for text and attributes: copy string value of node

Patterns


examples


root node
: /


(relative) element name
: e.g. Student, Person,
FirstName, Study


(relative) path
: e.g. Person/Study, Person/Study/Faculty


element at any level
: e.g. Person//Faculty, //Study


attribute
: e.g. @id, Study/Faculty/@id


wildcard:

*, cdo:*, Person/*/Faculty, //*/@*


“or” operator:

FirstName|Lastname, *|@*


test with [XPath expression]
:


Person[FirstName=‘Peter’],


Faculty[@id=1070],


Study[position()=last()],


Person[Study/Faculty/@id=1050],


Person[Study]

Sequence constructors


Sequence constructor can consist of


text nodes


literal result elements


XSLT instructions


extension instructions

XSLT instructions


creating new nodes


xsl:document, xsl:element, xsl:attribute, xsl:text,
xsl:value
-
of, ...


conditional or repeated execution


xsl:if, xsl:choose, xsl:for
-
each, ...


invoking other templates


xsl:apply
-
templates, xsl:next
-
match, xsl:call
-
template,
...


declaring variables


xsl:variable, xsl:param


other

Creating new nodes

<
an
-
element

an
-
attr
=“
a
-
value
”>
a
-
text

</
an
-
element
>

<
an
-
element an
-
attr
=“
{
expression
}
”>
a
-
text

</
an
-
element
>


<
xsl:element

name
=“
an
-
element
”>

...
</
xsl:element
>


<
xsl:attribute

name
=“
an
-
attr
”>
a
-
value
</
xsl:attribute
>

<
xsl:attribute

name
=“
an
-
attr

select
=“expression”/>


a
-
text

<
xsl:text
>
a
-
text
</
xsl:text
>

Conditional and repeated
execution

<
xsl:if

test
=“...”> ... </xsl:if>


<
xsl:choose
>


<
xsl:when

test
=“...”> ... </xsl:when>


<xsl:when test=“...”> ... </xsl:when>


<
xsl:otherwise
> ... </xsl:otherwise>

</xsl:choose>


<
xsl:for
-
each

select
=“...”> ... </xsl:for
-
each>


Invoking other templates


<
xsl:apply
-
templates

select=“...”/>


finds a template for each node in the input
sequence and invokes it


default:
all child nodes

(elements, PI’s,
comments, text


not attributes
!)


can be nodes that are not descendants

Variables

definition (global/local):


<
xsl:variable

name
=“...”
select
=“...”/>

<
xsl:variable

name
=“...”>...</xsl:variable>


use:


$
variable
-
name


e.g.
<xsl:value
-
of select=“
$
var”/>

Parameters

declaration (at the level of stylesheet, template, or function):


<
xsl:param

name
=“...”
required
=“yes|no”
select
=“...”/>


use like variables ($xxx)


When invoking templates:


<xsl:apply
-
templates ...>


<
xsl:with
-
param

name
=“...”
select
=“...”/>

</xsl:apply
-
templates>


XPath 2.0


all values = sequences of


nodes, or


simple values, e.g. int, string, boolean, date


single value = sequence of length 1


empty sequence: ()


single value: „a“ or („a“)


general sequence: („a“, „b“, „c“)


from www.saxonica.com

Constants


string literals


"This is a test.“


"This is a
‘test'."


numeric constants


14 (integer)


385.032 (fixed point decimal)


3.2e
-
7 (double precision floating point number)


no boolean constants


use true(), false() functions


other


xs:dateTime("1966
-
07
-
31T15:00:00Z")


xs:float("10.7")


...

Various


variables: $name


function calls: fnc(arg1, arg2, ...)


comparisons / tests / conditionals:


for atomic values: eq, ne, lt, le, gt, ge


for sequences: =, !=, <, <=, >, >=: true
if any pair

has that
relationship!


is (testing node identity)


deep
-
equal (node
-
sequence
-
1, node
-
sequence
-
2)


<<, >> (testing node precedentness in document order)


instance of, castable as


if (E1) then E2 else E3


some/every $x in E1 satisfies E2



Accessing documents


axis :: node
-
test


axes available:


child

(default), attribute (abbrev.
@
), ancestor,
ancestor
-
or
-
self, descendant, descendant
-
or
-
self,
preceding/following, preceding/following
-
sibling,
parent, self


node test
-

examples:


node name


prefix:*, *:localname


text(), node(), comment(), element(), element(Name),
attribute(), attribute(Name)

Accessing documents (2)


E1 / E2 / E3 means:


first we have an input sequence (of nodes), S1


then we apply expression E1 on each of them, resulting in S2


then we apply E2 on each of them, resulting in S3


then we apply E3 on each of them, resulting in S4


e.g.


/Students/Person[@id=‘12998800’]/Study


= /
child::
Students/
child::
Person[
attribute::
id=‘12998800’]/
child::
Study


results in two elements “Study”


/Students/Person/Study (three elements “Study”)


/Students/Person[@id=‘12998800’]/FirstName/text()


results in text node “Peter”


/Students/Person[@id=‘12998800’]/FirstName/string()


results in string “Peter”

<?xml version="1.0"?>

<
Students
>


<
Person

id
="
12998800
">


<
FirstName
>
Peter
</
FirstName
>


<
LastName
>
Kov
áč
</
LastName
>


<
BirthDate
>
1980
-
10
-
25
</
BirthDate
>


<
Study
>


<
Program

id
="
1.MAT
"></
Program
>


<
Faculty

id
="
1070
">
FMFI UK
</
Faculty
>


</
Study
>


<
Study
>


<
Program

id="
1.AE
"></
Program
>


<
Faculty

id="
1050
">
FiF UK
</
Faculty
>


</
Study
>


</
Person
>


<
Person

id
="
88332212
">


<
FirstName
>
Karol
</
FirstName
>


<
LastName
>
Nový
</
LastName
>


<
BirthDate
>
1982
-
11
-
16
</
BirthDate
>


<
Study
>


<
Program id
="
1.INF
"></
Program
>


<
Faculty id
="
1070
">
FMFI UK
</
Faculty
>


</
Study
>


</
Person
>

</
Students
>

Progress Sonic ESB

CustomerService wrapper


SOAP
→ ESB internal format


Abstract → Concrete XML syntax


ESB internal format → HTTP



(external service processes the message)



HTTP → ESB internal format


Concrete → Abstract XML syntax


ESB internal format → SOAP


Internal representation:
XQMessage and JMS message


Progress Sonic ESB Product Family

(a part of)

Orchestration

ESB

Messaging

queues

topics

services

service types

endpoints

ESB processes

ESB containers

BPEL processes

Sonic MQ

Sonic ESB

Sonic

BPEL Server

ESB Key Concepts


Service


Message


Endpoint


Container


Process


ESB Key Concepts

Service (“internal service”)


deployed piece of code

providing business or mediation
functionality


identified by name, e.g.
MyService

(or MyApp.MyService)


instance of specific
service type
, e.g.
MyServiceType


(Service
≈ object, ServiceType ≈ class)



custom
-
built or provided with Sonic ESB:


content
-
based routing service


XSLT transformation service


file handling services (pickup, drop, split)


split
-
and
-
join services


ESB Key Concepts

Service (cont’d)

A service has following endpoints defined:


entry endpoint:

for getting input messages


exit endpoints:

for sending output messages


fault endpoint:

for sending (recoverable) faults


rejected messages endpoint (RME):

for sending
unprocessable messages (e.g. when service throws an
exception)


These are
set administratively
, not hard
-
coded into

service

code (although service can send message to any

endpoint it wishes to).

ESB Key Concepts

Endpoint


an abstraction of
JMS queue or topic
accessible on
specific
JMS connection


identified by name, e.g.
Test.MyEndPoint

Connection Parameters:


URL
(e.g. tcp://broker:2507)


username & password


parameters concerning
session pooling

Endpoint Parameters:


connection


QoS (best effort, at least once,
exactly once)


JMS destination

(queue or topic)


message priority & time to live


...

ESB Key Concepts

Message


(an in
-
memory) equivalent of
JMS message


quite simplified:


contains
header

and 0 or more
parts


header:
application
-
defined

and
transport (i.e. JMS
-
) specific

data:
just like JMS properties and JMS header mixed together


parts: each has its own
header

and
data

(arbitrary java object)


when receiving/sending through JMS, JMS message is
mapped to ESB message and vice versa


ESB Key Concepts

ESB Container


a place where services live


provides all the necessary infrastructure for


loading, starting and stopping services


communicating with JMS broker(s) and external web services


loading necessary resources from Directory Service and caching
them


executing ESB processes


ensuring fault tolerance (via backup containers)


logging and auditing


services in a container can communicate locally,
bypassing the broker


default:
dev_ESBCore + dev_ESBTest

ESB Key Concepts

ESB Process


sequence of service
invocations

defined in
an
itinerary






Our solution