SlideShare una empresa de Scribd logo
1 de 155
Descargar para leer sin conexión
WS-I - Axis 2.0
WS-I - Axis 2.0

!" # $% &
'( ) * ! , ! !&
+
!& */ &
.
* 0
&
)
12
2
. #
#
3! 4 /
((( 5 !
/
WS-I - Axis 2.0

) ,!

#0! * !
! 6
7

(

!

!
Web Services Description Language (WSDL)

8 3 )6
,

! 9
WS-I - Axis 2.0
! 6
"#
(

3
!
# (

" ! 9 /
(
' *

,*!
' (!
)
(()

: (&
$

! !
, !

&3 !
3*

*

'&
&
$

*
' &

"#
&'
)
(!
)
)7-$
3( , ,
"#

% &

!

#
! /

#

#

)#

& ) '# !
* ) + (*

&

+ # +#

* -.)& 0 0 7.&
- &0

&(* "# + (
WS-I - Axis 2.0

*!
#

1
!
%#
)
'

((

+

?3
3 !, /
+ #+
!

!,; < 8 = 7 .
!
&

+ '
# '
'

7 .& # (

+ (

< 8%
*

' ( * "# + &

'

-> '
(

!

'

?8& # #

*
/ / / ( + '
*
'
'
) #+ &
&
# ' (

(! (
&
'# ' (

'
#+ # *

%
WS-I - Axis 2.0
(? 7 /
"#
'&
&

#

(

+!
+

!
# #

@
(

* "#

,

-* )
#
.* > ,
#

!/

/
&

(
& ! !
&

3
)
(

! /3 !
*
+/ *
& #
+

0* 0 !/ ! /
# )
#
*
#
)
!
2

! * "#

&!
#

! # )#
6
!

3
!
(! (
&
%#
*

# '
)

+
#
(
&
&
1
)

'

&

'

*
*

*

&

%# '
)
(! (
&
*
, !
"#
' & # )&
# 2

' (
WS-I - Axis 2.0

7 1'
"# '
)

(

!&
!
)& !
!
& '
&
"#

&

(
" !# )
!
!*

-

&

!
&

7 5 !

#
&

#
(

#

&# !
(% )
& & )&
+ !

(% !
' *

& )& !
+ !
( ( 3 #
# )
+/
(
#&
(
* "# ' %
/
*
.! & A
!
!
7

&

B <! 9

*! 7

) %
*

( & %
& &
#

&%

&
+

#

1
)

C

#
+

!

&+
WS-I - Axis 2.0

.
- D* !
$ 9
- / !6
WS-I - Axis 2.0

!
WS-I - Axis 2.0

%0$

. 3

!,#EE((( ( %
!
"#
(! '
&

)
(
! '

/
E. 3 E$

. 3 %

!

'

#
45
' -*-%
&
%&
# & '
% ' (
'#
! '
# #! (

'
%
!

'
!
&+

! !

+
WS-I - Axis 2.0
7 .
"#

&
&
+
6

7)
5)&

!

!

! ,8
& 4

&
*
# & +
9

3 +4
"" :

)(
"#

0
! '
"#

+' )

'
(
(

,
' (

!

&!

##

3

'

'
WS-I - Axis 2.0

! 7 .0 " !
F
6

+ '
)

5

&
&
& ""

(!
&
; +
&
& (! (
+ &

+!

&(

)

(!
)
WS-I - Axis 2.0
7 . ''. 1 - D* !

POST /WebCalculator/Calculator.asmx HTTP/1.1
Content-Type: text/xml
SOAPAction: “http://tempuri.org/Add”
Content-Length: 386
<?xml version=“1.0”?>
<soap:Envelope ...>
...
</soap:Envelope>
WS-I - Axis 2.0

7 .

/

!* !
*

SOAP Message

The complete SOAP message

Headers

Protocol binding headers

SOAP Envelope

<Envelope> encloses payload

SOAP Header
Headers
SOAP Body
Message Name & Data

<Header> encloses headers
Individual headers
<Body> contains SOAP message name
XML-encoded SOAP message name
& data
WS-I - Axis 2.0

A Sample SOAP Request
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml;
charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI“
<SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV: encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePrice xmlns:m="Some-URI">
<symbol>DIS</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WS-I - Axis 2.0
7 . - ,6

HTTP/1.1 200 OK
Content-Type: text/xml;
charset="utf-8"
Content-Length: nnnn
<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:GetLastTradePriceResponse xmlns:m="Some-URI">
<Price>34.5</Price>
</m:GetLastTradePriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WS-I - Axis 2.0

7 .

*!

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode> SOAP-ENV: MustUnderstand </faultcode>
<faultstring>SOAP Must Understand Error </faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WS-I - Axis 2.0

7 .
5)&

* !
6
""

!
*

) +

HTTPS
X.509 certificates
&!

<4 #
"
!
!&
!
=
&'
&
&
+
"+
! '

# #( #

/
!

/& &
! +
WS-I - Axis 2.0
?8 %

!

)

#( '
1.

Service interface definition
–

2.

Service implementation definition
–

&

#+

Abstract semantics for Web Service

Concrete end points and network addresses where Web Service can be invoked

&

(

+) ' &'+ )3
)
* "#
+!
! &#
)

# >

'#

!

#
& ) '&
)'
+ 4
'#

#
)
(
*

) #
#
)& '
&
+
* "#

%

' #
&

#
WSDL

WSDL Schema
Interface

Implementation

<definitions>

<definitions>

<import>

<import>

<types>

<service>

<message>
<portType>
<binding>

<port>
WSDL

WSDL Schema
Interface
<definitions>

• <definitions> are root node of WSDL
• <import> allows other entities for
inclusion
• <types> are data definitions - xsd

<import>

• <message> defines parameters of a
Web Service function

<types>

• <portType> defines input and output
operations

<message>
<portType>
<binding>

• <binding> specifies how each
message is sent over the wire
WSDL

WSDL Schema
Implementation
• <service> specifies details about the
implementation
• <port> contains the address itself

<definitions>
<import>
<service>
<port>
WSDL Elements
Open – allows for other namespaces and thus highly
extensible
Ability to import other schemas & WSDL
Provides “recipe” for Web Services
Provides both interface and implementation details
WSDL

Example
Demo: http://localhost/…/math?WSDL
http://localhost:8080/axis/services/urn:questhelloservice1
?wsdl
WS-I - Axis 2.0

!/
0! * !
#
(
? # '#
# 1 #
)
(( & )
+
# 1
)
'

!
!
'

4 #

& '

#
((
%
&
&
'& ,
&

&)
+

#
!
!

'

%

!
!

#
#
%

&!
(

' (

# 1 *
)
* "#
WS-I - Axis 2.0
/ %)
#
!
!

.7B ,,
7
% )
&
'& ,
&

) #
(

! & &
)
&
&
&@
! &
)
+ &
&
) $ & $: ( A
&
B
B

)

( @

&

#

+! 3

(

&
&
WS-I - Axis 2.0
!, # ) , ! B
&
! 3 !
3
!, # G ! H'7 ) 'I 7 >J K ( ,, K
K >$%0
"
!, # ) !
! 6
L 5L
,
!
>$%0
"
! 6
!, # '
& ,6!
3
!! ,5
! 6
!, # 0 '
3
!
!*
/!
&
! !!
! ,2 G ! !,#EE
#
!
!
#
E
E
E !
&
(
(
!, # " ( !,
6
!,#EE
!
!
#
(
!
/ /!
# # (!+(
&
3 #

E
L
,

3

E

E
E 6
@
=M
M!
L !
(
8 !*
!
! / /
!&
(
( / * !
, ! *!
,*!

#
#
# ? "(

)
*

'& ! +
)&
+ &

)

#
WS-I - Axis 2.0
B-

1

(! 6 / *
*6
(! 6 / *
*6
(! 6 / *
*6
C
! & &
)
&
&
C
#
+ & C
&
) $ & $:
&
B
B

!!

,
,
A

# A
(A
D ( ! E $ ! < (! * < &
# ,<
&
# &
&$% ( E $ &
&
&@
E $ , + & $%!
)
&
D ( E$ + &$! &
& )
( ! D ( E$ ( $
( @
( A

&$
WS-I - Axis 2.0
>
.7B ( ! )
7

#
/. 9 / "

! 3
3 (!
*
&
(! 6 / *
*6
A
C
! & &
)
@
! &
)
( @
E
A
*
$
$A
* D)
(
$ (
D)
-F A
$
)
A
B
B

1

, 6

5

,5

! 6
WS-I - Axis 2.0
&
# #
#
#
# % # # (!+ G
&
*
! 3
3 (!
*
&
! & &
)
@
!
A !
)
( A
! &
)
@
)
A
B
! &
)
@
#*
E
A
B
! &
)
D)
(
@
) )
( A
B
! &
)
D)
(
)
(
@
#* )
(
E )
( AB B

& %

#

&

&& 3&
&
3
WS-I - Axis 2.0
D
#
D /%

#

(!& #
) / .*/ '
(& &

)
! +
&

#

# +
'&
&
+ # / .*/ '
(& &
( ,, K
K >$%0 K
"
3K
H ! + /
&
E$ $
*6
+ ! 6$
E$
& E$ * ! # * / .* ! +
& ( * G
! + $I
&
<
"# / !
K >$%0 K , 5
"
3 ! (
# + (

! # *6 '
&

# #
!& # #
!+

"
# # #!
!
%'" (
# ! < & ,J J < / .
,< & #
KK

( 3
*
)

G
#
& # *6 ' *
&

H'7 ) 'I 7 >J K

H'7 ) 'I 7 >J K (

+

')

# &2

' *6 ' *
&
&

#

,, K

/ .*/ %
(&

#
WS-I - Axis 2.0
? , 6 /

C

/

! /!
H
( E$ &
&
$
I
H
! I
"# (+'
% # # + #&
&
H<
! I
H,
!
=M
)
MJ
H !
=M 6
MJ
H
/=M / ,
,
-.)
H< !
I
H<
I

HE,

/-

!J

MEJ
WS-I - Axis 2.0
)

!/

"# / !
(! (
&
& %
#
# ' & 3& #,
&
3

# '
&
*/ ' * "#
(& &

# (!&
& &
'
) )

'#
'#

&
&
&*
?" 4
D=
*/
(&
&
&
&* &
! + #
&
+ )

6
)
/.

(
!

'
+
*

!
!

#

#

'
&

#
WS-I - Axis 2.0
?3
3
(

!

6 3, 3 /
6
%#

/ & + '! '
+

(

'

,
! '(
+

# !

! '(
+

#

! '
+
1
) *

& &
(

& &
'

# !

*

& & #
'

#&

*

#(

# !

%

#
WS-I - Axis 2.0
,

3
6

/ -

!!

8

3 !
WS-I - Axis 2.0
G *,

/

"# ( + ( +
#
& & &
&
+
#
! '
7 )*
!
(

9 9 !

H
7 )I
!
H
=M 6
************************
H<
I
H
=M 6
***********************
H<
I
H<
7 )I
!

&

(

MJ

MJ

! +() !
&
& &
# ' *"
&

# #( +
# % /.# #
WS-I - Axis 2.0
/'
%. ! - *
6
"# ( + ( +
#
& +3
#
#
!
& &
*
+
*
?" 4
D=
*/
(&
&
' *6
*6

)
(

)
&

#
/.

! +& +
&
(

)

*
#

?8
#
'
&
#
?" 4
D=
(+

(! / ! &
&
!
%
&'
&
# ' * / *! !
& +
*/
(&
*
&

#

#

'
&

#(
WS-I - Axis 2.0
/'
%. ! - *
6
"# ( + ( +
#
& +3
#
#
!
& &
*
+
*
?" 4
D=
*/
(&
&
' *6
*6

)
(

)
&

#
/.

! +& +
&
(

)

*
#

?8
#
'
&
#
?" 4
D=
(+

(! / ! &
&
!
%
&'
&
# ' * / *! !
& +
*/
(&
*
&

#

#

'
&

#(
WS-I - Axis 2.0
)

! !
%

/.#

! ,,
)&

7
#
=& #
&
) #
! +#
&

)!
!
)#

N ! ! /3
'
#

?8
*

&
+

# '&
&

3&
*
# )

3&

#
!,

'

(

#

%

#

*

)& ' *
&

G
! /)
/. (
#
' &
( 3 #
3
*
,
3&
& %
*
&
%
)& '
&

#

'
&

) !&
!

4 ? !)
&

(

#

'

'# (

/.

)

.

%

*/
(&

*
WS-I - Axis 2.0
,

#C

? 3* !)

%G

!

7,!

!G

7
#
' * "#
&

+ '# / .
+
) %
'
&
& & # (! < &
&
# ') !
&
,

I

) **L (! L
&

& *
.6

"
!
* 5)%
! +
&
)! &
)
)

& / . (!
L
&

' (
#

'
&
((
#)
# 2 L ,!

)

!

%

) # #
+ "# ' &
*
&

*

&

3&

)
#

# #&
&
((

M

% )#
+
!
#
* "# 2 2&
'
# #
# 2 2& &
'
# # 2 2& % #
'
!
/ .* 4
% )
+
& ! ' #
+
WS-I - Axis 2.0
,

#G

!

0! 3

0 !

"#
# #
#+ ( ! )
&
(! (
&
# / . +)
# 2 2
I
"#
#
#

& *
.6

) **L (! L
&
)

3 )

!)

&!

#
'
' #
')
' ' ,
&

& / . (!
L
&

# (
(
&
&
%)
'
) %
# )
'
& *

'
'
!
&

*

&

' # 3& %
* "#
&
+

#

3&

!
&

'

+&

# (
# (! (
&

& *

' ) %#
*4
%
#
'
WS-I - Axis 2.0
,
I

#G

& *
.6
/.
/.
/.
1
)
/.

(!
&
(!
&
(!
&
* ?#
(!
&

! /)

!
%

) **L (! L
&

)
& / . (!
L
&

) ) E
) *? #
) *? #
( $ & $A
&
) *? #

*

&

)

/ . (!
&
( 1
) E
( A
)

!

) A

E )* #

1
)

A
WS-I - Axis 2.0
>

*
!

)

&
/
( ( + # &
*
3 ' ( #
& #
#
(
(
+#
# &

&

& %#
/

%# +

3 !# !
/ )
#
&
3
## ! ' # &
)
&
)
&& (
&
)
/
#! N
*
! (
/

*

/.# #
(
# (

! &+ ! )
' '
&

# (

/ )
)*

% # #(

# #
WS-I - Axis 2.0
!/

,

(! # & # /
&
#
! & &
)
(!
&
& /
@
! & (!
)
&
&
@
B
! &4
)
!
3
<
<
# !
& #
<
<
( #
) 4
!
* D"4
D>?A
B
B

& &
&

/(

&!
& !

/ #

'&
&

,

/ =) @
&
WS-I - Axis 2.0
D

#
)

)

)
& '#
)
3( # *
& '#
)
3( # ,

! *#'

*,

! 9 ! !!

#'

! 9 ! !!
! !3 : !

!
!'
#
!!

3

#

/

#

&
)

6! / 3 (

/
*!

# '&
&

!

!3 (

*,

! 9 ! !!
! /(
(!
/ !/ 3 (

/( ! !

/&

#
WS-I - Axis 2.0

.
"#
! '!
#
# & * !
#
4

)
'
&

+ / .%
( &
+ )!
!
)
(
' +,

& &
&

'#

& *

4

! ' (

&

# (

4

)3

# + (

!
#
'
&

/ )

# #
#

#

&

! #
)

/ )

*

&*

*
&
&

'!
#

'
WS-I - Axis 2.0

#
& #
&
3( #
•= % # 3 # # # !
•"#
# 3 # # # ! = #
#
•D /%#
'# # &
&
&
•4 # !
'
#
# &
# %#
•= & %
&
+
&# 3 # # # !
&

'# ! % # # '&
#
&
/ )
' *
&
# *4
' !
%#
&
&
3 %/ ! ' # !
#
# &*
&
&
3 *
'
'
# (

1
)
3 *

*

,
WS-I - Axis 2.0
'6
,

3.

"#
+ # &
' * "#
'

+
! '!
#
'
(! (
&
*
+
! '!
#
,

/ .*/ * "#
(&
%# &
'# !
#

'
'

#
# / )

#

-* 7& & #
!
.* !
!
#
G

.

& &#
!
(
(
7, !
=
(

!
#

#
3
# + (% &
&

.
%) !
!
#
# + (% #

#

#

!
'#
* 4 (!
&
# )# # & &# *
!

& %#
) # '

#
&

) '
'!

(%#

+(
*
WS-I - Axis 2.0
.
,
H#
H
H<
#
,
H#
H
H<
#
3
H#
H
H<
#

-*
!
& ( E$ (! O
&
& $ & E$ * ! # * / *# & * (!
&
! E$ ! -$! = E$ ) $ I
#
) #
#
<
&I
8 !
& ( E$ (! O
&
& $ & E$ * ! # * / *# & * (!
&
! E$ ! -$!
#
) #
#
E$ ) $ I
<
&I
& ( E$ (! O
&
& . $ & E$ * ! # * / *#
! E$ ! -$ ' E$ (! O
#
) #
&
& $I
<
&I

& * (!
&

& $
I

& $
I

&.$
I
WS-I - Axis 2.0

3
!
H# & ( E$ (! O
&
& 0 $ & E$ * ! # * / *#
H
! E$ ! -$ ' E$ (! O
#
) #
&
& .$ I
<
H<
# &I

& * (!
&

3
H# & ( E$ (! O
&
& P & E$ * ! # * / *# & * (!
$
&
H
! E$ ! -$ ' E$ (! O
#
) #
&
& -$ ' E$ (! O
&
H<
# &I

&0$
I

& PI
$
& .$ I
<
WS-I - Axis 2.0

(
=&
(!+
&
&
&
'!
# * "#
/ .*/ *
(&
!
#
& & &
&
)
(
# / )
#
&
&
"# ' &
&
# ') +
! ''
&
-* 4 =&
.* ) =&
0* 4 = ) =&
&
P ) = ) =&
*
&

'!
#
# #
'
'# & *
/ .,

'
&
)&

'
!%'
&
WS-I - Axis 2.0
!/

* 1

*

!* ! $
*

(
WS-I - Axis 2.0
* )

3/ !
*

O

*

P

(! ( ) */ ' #
&
& (& &
&
+
# & ) #
(
(! /( ) %
&
&
#
( #
')
( ) */ * = % 2 & 3 # +
& (&
&
! '
')
& & ( ) */
& (& #
/ (! ( ) % # # )
&
&
&#
&
(
)
(
%
)
# #
,
&
#
(
) (! (
&
&
&+
? !

)
&
&
WS-I - Axis 2.0
.

-*

"# ' &
&
4 &(
(!
?/

#

')

#

* ! # * / .*
*
* ! # * / .*# & *

! & & 4
)
)
! &4
)
<
< #

+ '

)

(

)

&

&

/ .,

'
&

&

& /

& (! (
&

@
!
3
! ! +' ( #
/

')

/(
')
/ E(

/ #

/ =) @
&

/
/*

')

/ A
WS-I - Axis 2.0
4
) E
4
')
<
<
(
# )
) E4
* & '
)
<
< #
)
3
')
/*
<!
<
)
+ (* ) *! & T
"#
) 4
!
B
B

/*

! +4
D

4
D7O ?

) * S & : -: T A
)
U
#
')
/
! +4
D
4
D7O ?
(
*

(
D"4
D>?A

)

7?O
T:

7?O

>D"O
Q?R A

>D"O
Q?R% ) A
) A
WS-I - Axis 2.0
(

) )#
&
#
&# & !
&
#
'
)%
&
# # /?
* "#
+ )
#
!
+
!
& '
& ,
4
!
* D"4
D>?, 7
#
&
4
!
* > ?D ,
+
' *
#
!) # / ) %
4
!
* 5 ", ( # #
& #
3
) * '& ,
&
"#
! &
)
@

!
'

)

&
&

3( # %
) %)!
%
& * "#
)
&& )

#)
&
)

) # (
*
( '#

)
*
*

#

'

!# (

%# # !
!

)

4
D
4
D7O ?
>"7 4
D7O ?
>D"O ?O
=4 D
B

&

#

7?O >D"O
Q?R E $ (
7?O >D"O
Q?R E $ )
?O ?=4 E $ ) O
$
A

(
(

) $
A
) $
A

%
WS-I - Axis 2.0
( !!

*/
!

/

/

*!

! & &
)
)
)
& /
& (! (
&
)
@
! &4
)
!
3
/(
/ #
/ =) @
&
<
< # )
! ! +' ( #
')
/
')
/
')
/ E(
/*
')
/ A
4
) E
4
')
/*
! + >"7 4
D7O ?
7?O >D"O
Q?R A
<
<
(
# )
) E4
* & ' ) * S & : -: T A
)
)
U
<
<
3 #
')
')
/*
! + >"7 4
D7O ?
7?O >D"O
Q?R% ) A
<!
<
)
+ (* ) *! & T
"# )
(
)
T: ) A
) 4
!
* D"4
D>?A B B
WS-I - Axis 2.0
* 0 ,
#
)
(

!!

)
!

& &! &
!

%
%

) #
#
&
'#
)#
! ! +' %
&
) #
!
%
* "# ' % !
&
1
)
#
) ! # &
& )
)( )*
&
3
# # & )
& #
+
1
)
(
# + (%
# + (
&
( * "# ( ) (! (
&
&
& !
+
#
+ (
&
&
& + ( #
&
)
( !
*
# (
%
# ( ) (! (
&
&
&
!
&4
* '
3 # / . ')
&
( )%
&
#
( ) (! (
&
&
& *= )
! ! %
)
&
&
( ) (! (
&
&
&
# ,
WS-I - Axis 2.0
! & &
)
)
) (! (
&
&
)% )
&
@
!
' &
>D" O
?D" E $ ) $
A
!
' &
"4 ? "
O
=
" E $+
+
(( $
A
!
' &
=4 ?O >==4 E $ !
*!
$
A
! &
)
')
/
')
/%
/
) /
&
) #
&
/ =) @
&
<
<
& ) )
+ (* ) *! & $
#
, ( ) $A
&
)
')
/% D
4
4
D7O ?
7?O >D"O
Q?R A
)
')
/% >"7 4
D7O ?
7?O >D"O
Q?R A
B
!
)
')
/
')
/%
3+ @
4
) E 4
')
/*
! +3 +A
' ) EE )&@
&
')
/*
! +3 + 4
%
* & '$ $ A B B
)
K
WS-I - Axis 2.0
! &
)
D ' /
+
!
/
!
#
/ =) @
&
+ (* ) *! & $
#
D ' : /
+$
!
A
B
! &
)
&
)!
!
@
< )
<
# # ! &+
)!
!
) '& A
B
! &
)
! & & + & +! & +
!+
%
/
!
/
!
#
/ =) @
&
<
<
') )
)
# !
! &+
V
B
! &
)
#
)
')
/
')
/ #
/ =) @
&
<
< & )
!
#
2
&
&
# &
) '# < )
<
'
&
+@
(!
&
= ( ' ( E
(!
&
= ( "4 ? "
O
=
"A
WS-I - Axis 2.0
=& ) =& E
=&
>D"O ?O
=4 D
?O ?=4 : ' ( *' (
=4 ?O >==4 A
' V ) =&* /
@
) =&*
D =& A
B
!
! !E
!
A
! !*
! +4
D
4
D7O ?
7?O >D"O
Q?R%
')
/*
! +4
D
4
D7O ?
7?O >D"O
Q?R *
! !*
! + >"7 4
D7O ?
7?O >D"O
Q?R%
')
/*
! + >"7 4
D7O ?
7?O >D"O
Q?R *
<
<
'
&
! !*
=& ) !
)
( ) =& % >D" O
?D" A
B
# 4 ?/ !
@
< ' #
<
/ !
26 !
&)
&
(
& <
<
+ (* ) *! & $
) '& V
?
$: *
A
B
BB

:

A
A
WS-I - Axis 2.0
! /!
*
H( )
& ( E$ )
& E$ * ! # * / .*
H
! I
) #
(
H4 =& I
H# & ( E$ (
4
& E$ * ! # * / .*
H
! E$
#
" !
' E$
5
H<
# &I
H< =& I
4
H )=& I
H# & ( E$ )
& E$ * ! # * / .*
H
! E$
#
H<
# &I
H< ) =& I
H<
( )I
&

)$
&
(! *( ) * 1 *
&
& )
)

(

)

H<

)$
&I
!

)
&$
(! *( ) * 1 *4 (
&
& )
$ ' E$ 1 > 4
)
5
! # $I
<

(! *(
&
)$ I
<

)
&$
)* 1 * )
& )

I

)
! # $

&$
I

)

&$
I
WS-I - Axis 2.0
? , 6 /

> / / /!

*

D
+ &
& ?" 4
D=)
( ) */ '
& (& &
* "# % ) &
&
?" 4
D=
( ) */
& (&
)
)
4 (
)
D
(

+
%
'& ,
&

! #
+

* &
)* &
&
)
&* &
)
&* &

W4 ' ' ( # &
&
) *( *
&

# &
+ &!
& !

+
%

( # W4 '
&

)
WS-I - Axis 2.0
4

# (

)
&

# + (% &
'&

#

!

& ,

-* 7
# ! < & ,J J < / .<
,< & #
KK
*
.* & 3
#
!! ! '
!(
, *,
(, / ! ! 9 3
*
, (
0* "+ $ ( $ )
!
(
$ / .$ !
%#
& ! ) # (
&
!
&*
P "# & 3
*
#
*
!
3%
!
/!
*&
(
3
* ) *!
*
#
*!
* #'
* !!
/
*! /
/
/ FD
*
> //
* K
&
(
(
, *,
(, / (!
,%
*
N &
*
*!
* 3
!
,% (
*&
9 //
XD % ) &
*
+
& # ( ) $ )
&
)$
&
)
'& *
)&
+
J "#
*
G
)
Q *(
!
!
0
/
/) * !
! ! , !,
!
(
- D* ! $
C-0
? ,!
7 . ! $
? ,!

(

(
WS-I - Axis 2.0

)
$

! .0
9 /
" %$ 9 / 0
!
# 6
)
) %#
(
+ #
) & 3
&3
3 #
) & )
+
#
%# ! &
!
& 3) & )
+

+ ') &
%+ #
)
*4 #
'+ #
)
% )
+
!
* "# ' % #
'+ #
)
#
!
*
WS-I - Axis 2.0
'6 # )
,

!/

)

!*

/ 0 ? 3 * !)
!

!* !
WS-I - Axis 2.0
#0
!, # )

!

9 /

$
)

!, # ) !
7 >
& 8 ,
<
!!

! 6*

9 /
/

6 3!

O

!* !

!3 ! , 6
O ! 3 !
*!
<0 & (
7
!

OPP
! !

!

3! 7 .
!7 >

! &
)
?&(
+
@
=
+' E
=
+
*
=
+A
D ( !
(D E ' *
D ( !
$ ! < * ! #*
# ,<
?&( ( # E ' *
?&(
$ # $ (D A
%
?&(
& E' *
)
?&(
$ & $ (D A
) %
& * "/$ & % '
)
& (+
)&
$A
( # *
#& & A
)
) ( # A
B

6 0
P
!

< / .$ $ -$A
%
WS-I - Axis 2.0
!, # $ 3
9 /!
&
(
!
!
! ! O, , ! /
6
P
5 !
7,!
!! !!
) !'
5 !7,!
!
, , ! *
! / !>.- O> . !- 3
P& 7 . ! &
! , ! !&
&
!
3/ !
*
!
3 !
! ' 3 ( /
,, ! (
((
! ! 7,!
5 !
3 !
#
&

E

<
<
!
6
!
! E
!
A
<
<
?
! * "
? !
'
$ ! < *K *-,J J < / .<
# ,< -.X *K K K
<
<
! *
$ , # $A
)
<
<
!
*
!
! A

&

A

< +

&

$A
WS-I - Axis 2.0
!, #
* !

! .03
.0 ! , /
&
/!

?&(
+ (* ) *!
) #

9 /
9 * ! !/ !

E *
&
A
(!
&

H , #
!
/
(& , E$ ! < * ! # *
# ,<
H ) I
& "# (+'
&
H< ) I
H< , #
!
I

+

%

&
&

# '&
&

< / .< $
/ I

9 /
,

A

)! ,
)

(
WS-I - Axis 2.0
D

,
#
*
')
&
)
#
#

)

4'
+
% !

3

&3
3 &'
+
)& &
& )
/

(
! (

* ( (
#
&
+ # )
'
+ #

*
#
) # '&
&
YD ( !

&
+ # )
)
( #
##
% ?&(
&( A

, & 3(
!
) ! 6*
* ! , !
(
!
&
E
&
)&
&
%
> $ ! < & ,J J < / .<
# ,< & #
KK
< +
*
YD ( $ ! < * ! # *
# ,<

/

%
( *

!

/!
(#

?8

& %)& )&
$ & &A
%
< / .$$ # $%
%

+ (

&
!

+

& %

(

!

A
WS-I - Axis 2.0
O

-

4
( #
4 #

# C! + /
" $ 9 /
OPP
3
) ?
( ' (! (
&
%
#

'&
&
!# '&
&
&
E
&
!
! E
!
A
! * "
? !
'
$ ! < *K *-,J J < / .<
# ,< -.X *K K K
! *
$ , # $A
)
*
!
! A

"

%$

9 /

+ #
)(
+ #
) +
!
!0

)

A

$A

#

4 "#
*

'

%)

,

-% # )

,

< +

%

+(

!P
WS-I - Axis 2.0
<
<
& 3 6
&
/ & 3 & 3E
&
&
! &
)
+ (* ) *! &
(
/* ? &!
(! E ) A
&
B
! &
)
=)
&
+ (* *! (
B
! &
)
?
?/
*!
3
"
A
B
! &
)
(!
&
(! E ) A R
&
BA

/

*

/*
!

@

& 3 @
&
/(

5 +*

=

/(
? &! *
@

/ @

?&(

A

/ @
A
WS-I - Axis 2.0
<
< 3 #
*
D 5& 3
+
% & 3A
&
+ (* ) *! & $
4 3 #
$A
/E K
A
<
<
&+ )
&
#
!
%
&! &
!
+)
<
<
#%
#
!
/. &
& '< & 3 # + )
+< & %
(! (
&
& 3
&
#
+)
%< +
<(
)
!
7>4
#& V (!
& @
"# * & ! -K KA
K
/
::A
'
/I -K @
#
/ =) $
& "( ) $A
B
B
WS-I - Axis 2.0
# C! + /

0 %7 6 >. O

&
E
&
!
! E
!
A
! * "
? !
'
,! ! ! OM* #*, ! MP:
*
!
! A

3

/!
O

/!
OPP

A
$ ! < *K *-,J J < / .<
# ,< -.X *K K K

!. 6
8

OPP:

< +

$A
WS-I - Axis 2.0
# C! + /

0 %7 6 >. O

"#
4&
3
0% 3
! // (
#
0
#(
!. # ) ( ) #
&

+ !

%#

& '
+ '

/( ! !
#
%

*!
OPP
# )&
3

&
!

!

3 #
!0

#

&
E
&
A
!
! E
!
A
! * "
? !
'
$ ! < *K *-,J J < / .<
# ,< -.X *K K K
,! ! ! OM* #*, ! MP:
*
!
! A

-

*!
O

!. 6
8

OPP:

3
) (
# '&
&

< +

)
!-

*
(

,

$A
WS-I - Axis 2.0
Building Web Services the REST Way

What is REST?
REST is a term coined by Roy Fielding in his Ph.D. dissertation [1] to describe
an architecture style of networked systems. REST is an acronym standing for
Representational State Transfer.
Here is Roy Fielding's explanation of the meaning of Representational State
Transfer:
"Representational State Transfer is intended to evoke an image of how a welldesigned Web application behaves: a network of web pages (a virtual statemachine), where the user progresses through an application by selecting links
(state transitions), resulting in the next page (representing the next state of the
application) being transferred to the user and rendered for their use."
Rest
REST uses the following standards:
HTTP
URL
XML/HTML/GIF/JPEG/etc (Resource Representations)
text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
Rest – A sample Illustration
Parts Depot Web Services
Parts Depot, Inc (fictitious company) has deployed some web services to
enable its customers to:
get a list of parts
get detailed information about a particular part
submit a Purchase Order (PO)
Let's consider how each of these services are implemented in a RESTful
fashion.
Rest
Get Parts List
The web service makes available a URL to a parts list resource. For example, a
client would use this URL to get the parts list:
http://www.parts-depot.com/parts
Note that "how" the web service generates the parts list is completely
transparent to the client.
All the client knows is that if he/she submits the above URL then a document
containing the list of parts is returned.
Since the implementation is transparent to clients, Parts Depot is free to modify
the underlying implementation of this resource without impacting clients.
This is loose coupling.
Rest
Here's the document that the client receives:
<?xml version="1.0"?>
<p:Parts xmlns:p="http://www.parts-depot.com"
xmlns:xlink="http://www.w3.org/1999/xlink">
<Part id="00345" xlink:href="http://www.parts-depot.com/parts/00345"/>
<Part id="00346" xlink:href="http://www.parts-depot.com/parts/00346"/>
<Part id="00347" xlink:href="http://www.parts-depot.com/parts/00347"/>
<Part id="00348" xlink:href="http://www.parts-depot.com/parts/00348"/>
</p:Parts>
Assume that through content negotiation the service determined that the client
wants the representation as XML (for machine-to-machine processing).
Note that the parts list has links to get detailed info about each part. This is a
key feature of REST. The client transfers from one state to the next by
examining and choosing from among the alternative URLs in the response
document.
Rest
Get Detailed Part Data
The web service makes available a URL to each part resource. Example,
here's how a client requests part 00345:
http://www.parts-depot.com/parts/00345
Here's the document that the client receives:
<?xml version="1.0"?>
<p:Part xmlns:p="http://www.parts-depot.com"
xmlns:xlink="http://www.w3.org/1999/xlink">
<Part-ID>00345</Part-ID>
<Name>Widget-A</Name>
<Specification xlink:href="http://www.partsdepot.com/parts/00345/specification"/>
</p:Part>
Again observe how this data is linked to still more data - the specification for
this part may be found by traversing the hyperlink. Each response document
allows the client to drill down to get more detailed information.
Rest
Submit PO
The web service makes available a URL to submit a PO. The client creates a
PO instance document which conforms to the PO schema that Parts Depot has
designed (and publicized in a WSDL document). The client submits PO.xml as
the payload of an HTTP POST.
The PO service responds to the HTTP POST with a URL to the submitted PO.
Thus, the client can retrieve the PO any time thereafter (to update/edit it). The
PO has become a piece of information which is shared between the client and
the server. The shared information (PO) is given an address (URL) by the
server and is exposed as a Web service.
Rest
Logical URLs versus Physical URLs
A resource is a conceptual entity. A representation is a concrete manifestation
of the resource. This URL:
http://www.parts-depot.com/parts/00345
is a logical URL, not a physical URL.
Thus, there doesn't need to be, for example, a static HTML page for each part.
In fact, if there were a million parts then a million static HTML pages would not
be a very attractive design.
[Implementation detail: Parts Depot could implement the service that gets
detailed data about a particular part by employing a Java Servlet which parses
the string after the host name, uses the part number to query the parts
database, formulate the query results as XML, and then return the XML as the
payload of the HTTP response.]
As a matter of style URLs should not reveal the implementation technique
used. You need to be free to change your implementation without impacting
clients or having misleading URLs.
Rest
REST Web Services Characteristics
Here are the characteristics of REST:
Client-Server: a pull-based interaction style: consuming components pull
representations.
Stateless: each request from client to server must contain all the information
necessary to understand the request, and cannot take advantage of any stored
context on the server.
Cache: to improve network efficiency responses must be capable of being
labeled as cacheable or non-cacheable.
Uniform interface: all resources are accessed with a generic interface (e.g.,
HTTP GET, POST, PUT, DELETE).
Named resources - the system is comprised of resources which are named
using a URL.
Rest

Interconnected resource representations - the representations of the resources
are interconnected using URLs, thereby enabling a client to progress from one
state to another.
Layered components - intermediaries, such as proxy servers, cache servers,
gateways, etc, can be inserted between clients and resources to support
performance, security, etc.
Rest
Principles of REST Web Service Design
1. The key to creating Web Services in a REST network (i.e., the Web) is to
identify all of the conceptual entities that you wish to expose as services.
Above we saw some examples of resources: parts list, detailed part data,
purchase order.
2. Create a URL to each resource. The resources should be nouns, not verbs.
For example, do not use this:
http://www.parts-depot.com/parts/getPart?id=00345
Note the verb, getPart. Instead, use a noun:
http://www.parts-depot.com/parts/00345
Rest
3. Categorize your resources according to whether clients can just receive a
representation of the resource, or whether clients can modify (add to) the
resource. For the former, make those resources accessible using an HTTP
GET. For the later, make those resources accessible using HTTP POST, PUT,
and/or DELETE.
4. All resources accessible via HTTP GET should be side-effect free. That is,
the resource should just return a representation of the resource. Invoking the
resource should not result in modifying the resource.
5. No man/woman is an island. Likewise, no representation should be an
island. In other words, put hyperlinks within resource representations to enable
clients to drill down for more information, and/or to obtain related information.
Rest
6. Design to reveal data gradually. Don't reveal everything in a single response
document. Provide hyperlinks to obtain more details.
7. Specify the format of response data using a schema (DTD, W3C Schema,
RelaxNG, or Schematron). For those services that require a POST or PUT to it,
also provide a schema to specify the format of the response.
8. Describe how your services are to be invoked using either a WSDL
document, or simply an HTML document.
Rest – POX over HTTP
import javax.xml.bind.annotation.XmlType;
@XmlType
public class Product {
private String id;
private String name;
private double price;
public Product() { }
//Getters and Setters omitted...
Rest
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ProductCatalog {
private List<Product> products;
public ProductCatalog() {
products = new ArrayList<Product>();
Product p = new Product();
p.setId("123");
p.setName("Shirt");
p.setPrice(159.95D);
Product p2 = new Product();
p2.setId("456");
p2.setName("Monkey");
p2.setPrice(2500D);
products.add(p);
products.add(p2);
}
Rest
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
@Override
public String toString() {
return products.toString();
}
}
Rest
public class SimpleRestServlet extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {
public SimpleRestServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
System.out.println("DoGet invoked on RESTful service.");
ProductCatalog catalog = new ProductCatalog();
Source xmlSource = asXml(catalog);
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/xml");
StreamResult st = new StreamResult(out);
try {
Rest
Transformer t =
TransformerFactory.newInstance().newTransformer();
t.transform(xmlSource, st);
} catch (Exception e) {
throw new ServletException(e);
}
System.out.println("All done.");
}
private static Source asXml(ProductCatalog pc) throws ServletException {
System.out.println("Marshalling...");
Source source = null;
Document doc = null;
try {
JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
Rest
Marshaller m = ctx.createMarshaller();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.newDocument();
System.out.println("Products=" + pc);
m.marshal(pc, doc);
System.out.println("Marshalled catalog to XML.");
} catch (JAXBException je) {
throw new ServletException(je);
} catch (ParserConfigurationException pce) {
throw new ServletException(pce);
}
source = new DOMSource(doc);
System.out.println("Returning XML source.");
return source;
}
Rest
REST
Rest
REST
Rest
REST
Rest
Developing REST Webservices in MyEclipse – Using JAX-RS
1. Introduction
We will outline the process of developing a REST web service, deploying it to
the internal MyEclipse Tomcat server and testing it with the REST Web
Services Explorer.
The REST features in MyEclipse are based on Jersey, which is the reference
implementation for JAX-RS, the Java API for RESTful Web Services. We will be
creating a simple web service which we will use to maintain a list of customers.
MyEclipse also supports developing SOAP web services using JAX-WS; for
folks needing to develop and deploy WebSphere JAX-RPC or WebSphere JAXWS web services, please take a look at MyEclipse Blue Edition.
Rest
System Requirements
This tutorial was created with MyEclipse 7.0. If you are using another version of
MyEclipse (possibly newer), most of these screens and instructions should still
be very similar
Creating the REST Web Service Project
Invoke the wizard using File > New > Other > MyEclipse > Java Enterprise
Projects > Web Service Project.
Name the project restdemo and select REST (JAX-RS) from the list of
frameworks.
Click Next to move to page 2 of the wizard. On this page you can specify the
path at which the services will be available, the name of the corresponding
JAX-RS servlet and libraries which you wish to add to your project. For this
project the defaults are fine, so click Finish to create the project.
Rest
Instead of creating a new project, you may also add REST capabilities to any
existing Java EE 5 Web project. From the project's context menu,
select MyEclipse > Add REST Capabilities...
Creating the REST Web Service
Creating the Customer entity
To start, create a simple Customer class with id, name and address fields; this
class represents the Customer entity we will be managing with our web service.
Use the File > New > Class wizard, put Customer in
theName field, com.myeclipseide.ws in the Package field and Finish the
wizard. Replace the contents of the generated class with the following code:
Rest
we will be using XML as the serialization format, i.e. we will send and receive
Customer entities from the web service using XML.
The @XMLRootElement annotation on the Customer class is a JAXB
annotation which allows JAXB to convert this entity from Java to XML and back.
It is possible to annotate the fields and methods within the class to customize
the serialization, but for our tutorial the JAXB defaults are fine.
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Customer {
private int id;
private String name;
private String address; //write setters and getters
…} – Rest refer the Study Material
Rest
Mapping HTTPMethods to Operations Performed
HTTP Method Operations Performed
GET Get a resource
POST Create a resource and other operations, as it has no defined semantics
PUT Create or update a resource
DELETE Delete a resource
Rest
HowDoes Jersey Fit In?
Jersey is Sun's production quality reference implementation for JSR 311: JAXRS:
The Java API for RESTful Web Services. Jersey implements support for the
annotations defined in JSR-311, making it easy for developers to build RESTful
web services with Java and the Java JVM.
Jersey also adds additional features not specified by the JSR.
The latest version of the JAX—RS API's can be viewed at
https://jsr311.dev.java.net/nonav/javadoc/index.html
Rest
Working with Jersey
To successfully run the JAX-RS reference implementation, you need a lot of
JARs. It’s
probably easiest to put them on your server’s classpath, but you can certainly
add them
to your WAR’s WEB-INF/lib directory if you like. As of the current release, they
are:
• activation.jar
• asm-3.1.jar
• grizzly-servlet-webserver-1.7.3.2.jar• http.jar
• jaxb-api.jar
• jaxb-impl.jar
• jaxb-xjc.jar
• jaxws-api.jar• jdom-1.0.jar• jersey.jar• jettison-1.0-RC1.jar• jsr173_api.jar
• jsr250-api.jar• jsr311-api.jar• rome-0.9.jar• wadl2java.jar
Rest
Modifying the web.xml file
You need to modify your web.xml file to use the Jersey adapter servlet, much
as you
would when using JavaServer Faces:
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
Rest
Creating Hello World with Jersey
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.ProduceMime;
/**
* Simplest REST web service.
*/
@Path("/helloRest")
public class HelloRest {
/**
•Retrieves representation of an instance of
•HelloRest.java
* @return a string with HTML text.
*/
@GET
@ProduceMime("text/html")
public String sayHello() {
return "<html><body><h1>Hello from REST!</body></h1></html>";
}
}
Rest
Here you create a POJO that is annotated with
javax.ws.rs.Path. Its value attribute indicates the path where this resource will
be made available. The resource path follows the adapter servlet path, so you
will be able to reach an instance of this class at
<server>:<port>/<context>/<jersey-servletmapping>/<path-value>
By using the JAX-RS
@GET annotation, you indicate that the sayHello method is the one you want
to respond to HTTP GET requests.
Then use the @ProduceMime annotation to indicate the MIME
type you want to return on response. Here you use text/html, but you can use
any MIME type that makes sense for your application, including text/xml and
image/gif.
Rest
Creating a Single Path for Variable Resources of the Same Type
@Path("/products/{id}")
public class ProductResource {
@Context
private UriInfo context;
/** Creates a new instance of ProductResource */
public ProductResource() { }
@GET
@ProduceMime("text/plain")
public String getProduct(@PathParam("id") int productId) {
switch (productId) {
case 1: return "A Shiny New Bike";
case 2: return "Big Wheel";
case 3: return "Taser: Toddler Edition";
default: return "No such product";
}
}
}
Rest
Restricting the Structure of Values in a Path Template
@Path("products/{id:[a-zA-Z][a-zA-Z_0-9]}”).
@Path("/products/{id: d{3}}") - the input should be exactly three digits.
URL http://
localhost:8080/restexamples/resources/products/555,
Rest
Accessing Query Parameters
Use the @QueryParam annotation on your method parameter. Optionally,
include the @DefaultValue in case the query parameter you’re expecting is not
passed.
@GET
@Produces("text/xml")
public String getProducts(
@PathParam("id") int productId,
@QueryParam("results")
@DefaultValue("5") int numResults) {
StringBuilder result = new StringBuilder("<products>");
//return the number of results requested
for (int i = 0; i < numResults; i++) {
result.append("<p>Product " + i + "</p>");
}
result.append("</products>");
return result.toString();
}
Rest
Marshaling a Custom Type to XML in a Response
Problem You want your service to provide an XML view of a custom Java type
you’ve defined.
Hint: @XmlRootElement, and create a JAX-RS service that indicates that it
produces XML with the @Produces("application/xml") annotation.
shows a basic Java type that your service can automatically marshal to
XML using JAXB.
Employee.java with JAXB annotations to assist in automatic marshaling
package com.soacookbook.rest.xml;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="employee")
public class Employee {
@XmlElement(name="id")
int id;
@XmlElement(name="name") String name; }
Rest
public class EmployeeService {
private static Map<Integer, Employee> emps = populateDatabase();
public EmployeeService() { }
@GET
@Path("{id}")
@Produces("application/xml")
public Employee getEmployee(@PathParam("id") int empId) {
return emps.get(empId);
}
private static Map<Integer, Employee> populateDatabase(){
Map<Integer, Employee> emps = new HashMap<Integer, Employee>();
Employee e1 = new Employee(); e1.id = 1; e1.name = "Bill Gates";
Employee e2 = new Employee();e2.id = 2;e2.name = "Larry Ellison";
Employee e3 = new Employee();e3.id = 3;e3.name = "Steve Jobs";
emps.put(1, e1);
emps.put(2, e2);
emps.put(3, e3);
return emps;}}
Rest
Offering Different Representations of the Same Resource
Problem
You want your service to provide alternate views of the same resource.
Discussion
A standard browser will pass the MIME types it can handle by passing the
HTTP Accept header in its request. A typical request header sent from Firefox
looks like this:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
The client is telling the server that it would prefer to get HTML or XHTML, and
its next preference is to accept XML. The preferences are indicated not only by
the order in which they appear, but with the q parameter, used to specify a
relative “quality factor” or how strong the preference is for the given media type
on a scale of 0 to 1.
Rest
import java.io.File;
import javax.activation.MimetypesFileTypeMap;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
/**
* If we put a @Produces annotation on the class level,
* that will be the value matched despite browser preferences
* in the Accept header.
*/
@Path("/duke")
@Produces("text/plain")
public class DifferentRepresentations {
private static final String IMG_PATH =
"C:programs/eclipse/workspace/restexamples/WebContent/duke.gif";
Contd…
Rest
@GET
@Produces("text/html")
public String doGetAsHtml() {
return "<html><h1>Html Duke</h1></html>";
}
//notice no override, as this method returns the default
@GET
public String doGetAsPlainText() {
return "Plain Duke";
}
@GET
@Produces("image/*")
public Response doGetAsImage() {
File image = new File(IMG_PATH);
if (!image.exists()) {
throw new WebApplicationException(404);
}
String type = new MimetypesFileTypeMap().getContentType(image);
return Response.ok(image, type).build();
} contd…
Rest
@GET
@Produces("text/xml")
public String doGetAsXml() {
return "<?xml version='1.0' encoding='utf-8'?>" +
"<mascot>Xml Duke</mascot>";
}
}
//end
Rest
Creating a Resource
Problem
You want to provide a way for users to create a RESTful resource in JAX-RS.
Solution
Use the @POST annotation on a resource method to indicate that it accepts
HTTP POST data, and add the entity in the method with the incoming data.
Rest
@Path("user/{id}")
@Singleton
public class UserService {
private Map<Integer, User> userDatabase;
//create fake user database to keep example simple
public UserService() {
userDatabase = new HashMap<Integer, User>();
}
@POST
@Consumes("application/xml")
public Response postUser(User user) {
System.out.println("Post User.");
//save to database here...
userDatabase.put(user.getId(), user);
System.out.println("Posted user: " + user);
URI createdUri = UriBuilder.fromPath("user/" +
user.getId()).build(user);
System.out.println("post: createdUri: " + createdUri);
//return a 201 'created' status
return Response.created(createdUri).build();
}
WS-I - Axis 2.0

G
7

(3
"
WS-I - Axis 2.0
Learning Objectives
Understand the coming Web Services
revolution
Fundamentals of Web Services
Web Services Overview

Internet Business Processes Span Companies
Web Services Overview

Technology Fabric Must Span Companies Too
Web Services Overview
Possible Solutions

Distributed computing
Web sites (portals)
Web Services
Web Services Overview
Distributed Computing
Client/server model
Doesn‘t scale
Not secure

Distributed object model
Components: packaging and interoperability
Remoting: remote method invocation
COM, CORBA, Java RMI and EJB
Not Internet-friendly
Interoperability issues: poor/non-existent standards
Tightly coupled: still doesn‘t scale
Web Services Overview
Distributed Computing

3-tier Application Architecture
Great way to build scalable Web applications

But such applications are silos
Integration is an afterthought
They can be integrated behind the firewall
Even that can be a problem

They do not provide a way to integrate across the
firewall (i.e. over the Internet)
Web Services Overview
Portals

Ads
Mail

Other
Svcs

Calendar

Weather
Finance

News
Web Services Overview
Portal Limitations

No standard way to expose functionality
Integration is expensive and error-prone
Hard to outsource
Not designed to be used outside original
scope
The problem?
HTML is designed for presentation to people
Can’t repurpose it in a general, reliable way
Web Services Overview
What Is a Web Service?

The solution? Web Services!
A Web Service exposes functionality to a consumer
Over the Internet or intranet
A programmable URL
Functions you can call over the Internet

Based on Web standards
HTTP, XML, SOAP, WSDL, UDDI, with more to come

Can be implemented in any language on any platform
Black boxes
Component-like, reusable
Web Services Overview
What Is a Web Service?

A Web Service combines the best features of
distributed computing and portals and
eliminates the worst
Provides a mechanism for invoking methods
remotely
Uses Web standards (e.g. HTTP, XML) to do so
Web Services Overview
What Is a Web Service?

Web Services allow you to interconnect:
Different companies
Many/any devices
Applications
Different clients
Not just browsers

Distribution and integration of application
logic
Enable the programmable Web
Not just the purely interactive Web

Web Services are loosely coupled
Web Services Overview
What is a Web Service?

New paradigm for Internet development
Deliver applications as services
Richer, customer-driven experience
Continuous delivery of value/bits
Third-generation Internet
Web Services Overview Evolution

of the Web

HTML

HTML

HTML, XML

HTML, XML

Generation 1

Static HTML

Generation 2

Web Applications

Generation 3

Web Services
Web Services
The Web today
How Web services work
Web Services
The Web Today

Purchase courseware
Purchased

Designed for people to browse
Web Services
The Web Today

Purchase Courseware

?

Server to server is a problem
Web Services

What Are Web Services?
Allow applications to communicate across the
internet
Platform independent
Protocol independent
Synchronous/asynchronous
Statefull/stateless
BizTalk®
ASP.NET
Web Services
Class Courseware
WebMethod
GetPrice
Purchase
Web Services
Testing
Courseware
Test HTML Page
Web Services
WebServiceUtil
Courseware?SDL
Service Definition(XML)

Proxy
Web Services
Register for Course

Purchase Courseware

Proxy
Web Services Overview
Application Model

Partner
Web Service
Other Web Services

Internet + XML

End Users

YourCompany.com
Application Business Logic Tier
Data Access and Storage Tier
Other Applications

Partner
Web Service
Web Services Overview
Sample Web Services

E-commerce: order books, office supplies,
other products
Track packages: UPS, FedEx
Weather
Maps
Telephone redirection, customizable rules
and messages
Underlying Technologies
XML Is the Glue

Connectivity

Connect
the Web

Presentation

Browse
the Web

Connecting
Applications

Program
the Web
Underlying Technologies
Web Services Stack

Directory: Publish & Find Services:

UDDI

Inspection: Find Services on server:

DISCO

Description: Formal Service Descriptions:

WSDL

Wire Format: Service Interactions:

SOAP

Universal Data Format:

XML

Ubiquitous Communications:

Internet

Simple, Open, Broad Industry Support
Underlying Technologies
Web Services Stack
Discovery
Directory allows potential clients to locate relevant
Web Services
UDDI

Inspection allows you to locate documents about
Web Services located on at a given URL
DISCO

A Description language defines the format of
methods provided by a Web Service
WSDL
Underlying Technologies
Web Services Stack

UDDI

Link to Discovery Document (XML)
http://www.ibuyspy.com/ibuyspy.disco
Request Discovery Document

DISCO

Return Discovery Document (XML)

Description

WSDL

http://www.ibuyspy.com/ibuyspycs/InstantOrder.asmx?wsdl
Request Service Description
Return Service Description (XML)

Wire Format
Request Service
Return Service Response (XML)

SOAP

Web Service

Web Service Client

Inspection

UDDI or
other
directory
service

Directory

http://www.uddi.org
Locate a Service
Underlying Technologies
Web Service Wire Format

The Web Service Wire Format specifies how
specific messages are exchanged
HTTP-GET
HTTP-POST
SOAP

HTTP-GET and HTTP-POST use a minimal
HTTP interface to invoke Web Services
Limited support for data types

SOAP provides a robust HTTP/XML interface
Extensive support for data types
XML Overview
XML Basics

XML is designed to represent and transfer
structured data
In HTML:
In XML:

XML does not display or transform data
XML separates data from formatting and
transforming
HTML and XML are both derived from SGML
In different ways
XML Overview
XML Syntax

XML is composed of tags and attributes
Tags can be nested
Representing entities, entity properties, and entity
hierarchy
<ROOT>

<Orders OrderID="10643" CustomerID="ALFKI" EmployeeID="6"
OrderDate="1997-08-25T00:00:00" RequiredDate="1997-09-22T00:00:00"
ShippedDate="1997-09-02T00:00:00" />
</ROOT>
XML Overview
XML Schemas

XML schemas describe the structure of an
XML document
XML schemas describe the tag and attribute
specifications
Simple and compound data types

XML schemas also describe constraints on the
contained text
XML schemas and the DTD are mutually
exclusive
WS-I - Axis 2.0
WS-I - Axis 2.0
WS-I - Axis 2.0

Más contenido relacionado

La actualidad más candente

Normativa riferimento 81 08
Normativa riferimento 81 08Normativa riferimento 81 08
Normativa riferimento 81 08sebaber
 
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.owaj
 
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014Anders Westholm
 
CompTIA - Cloud Study - Full Report
CompTIA - Cloud Study - Full ReportCompTIA - Cloud Study - Full Report
CompTIA - Cloud Study - Full ReportAssespro Nacional
 
Pep program 04122011-1
Pep program 04122011-1Pep program 04122011-1
Pep program 04122011-1Andrew Cannon
 
Gate ee previous year papers 1992 2010
Gate ee previous year papers 1992   2010Gate ee previous year papers 1992   2010
Gate ee previous year papers 1992 2010Venugopala Rao P
 
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdf
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdfSpring 2010 closed memo assignment jellyvision v. aflac complaint pdf
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdfLyn Goering
 
Locality in long-distance phonotactics: evidence for modular learning
Locality in long-distance phonotactics: evidence for modular learningLocality in long-distance phonotactics: evidence for modular learning
Locality in long-distance phonotactics: evidence for modular learningKevin McMullin
 
Rachel Greenstadt: Security and Virtualized Environments: An Overview
Rachel Greenstadt: Security and Virtualized Environments: An OverviewRachel Greenstadt: Security and Virtualized Environments: An Overview
Rachel Greenstadt: Security and Virtualized Environments: An OverviewEvangeline
 

La actualidad más candente (17)

Normativa riferimento 81 08
Normativa riferimento 81 08Normativa riferimento 81 08
Normativa riferimento 81 08
 
Urban Agriculture Australia & Canberra City Farm
Urban Agriculture Australia & Canberra City FarmUrban Agriculture Australia & Canberra City Farm
Urban Agriculture Australia & Canberra City Farm
 
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.
Articulo 416 LeCrim. La dispensa de la Obligación de Declarar.
 
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014
Stefan Melesko - Branschens strukturomvandling, Nycketalsdagarna 2014
 
CompTIA - Cloud Study - Full Report
CompTIA - Cloud Study - Full ReportCompTIA - Cloud Study - Full Report
CompTIA - Cloud Study - Full Report
 
Pep program 04122011-1
Pep program 04122011-1Pep program 04122011-1
Pep program 04122011-1
 
V8n1a12
V8n1a12V8n1a12
V8n1a12
 
Motherloss
MotherlossMotherloss
Motherloss
 
Urban Agriculture
Urban AgricultureUrban Agriculture
Urban Agriculture
 
Gate ee previous year papers 1992 2010
Gate ee previous year papers 1992   2010Gate ee previous year papers 1992   2010
Gate ee previous year papers 1992 2010
 
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdf
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdfSpring 2010 closed memo assignment jellyvision v. aflac complaint pdf
Spring 2010 closed memo assignment jellyvision v. aflac complaint pdf
 
Apps Market Research
Apps Market ResearchApps Market Research
Apps Market Research
 
Locality in long-distance phonotactics: evidence for modular learning
Locality in long-distance phonotactics: evidence for modular learningLocality in long-distance phonotactics: evidence for modular learning
Locality in long-distance phonotactics: evidence for modular learning
 
Rachel Greenstadt: Security and Virtualized Environments: An Overview
Rachel Greenstadt: Security and Virtualized Environments: An OverviewRachel Greenstadt: Security and Virtualized Environments: An Overview
Rachel Greenstadt: Security and Virtualized Environments: An Overview
 
Zharfan comments
Zharfan commentsZharfan comments
Zharfan comments
 
Nutrición básica
Nutrición básicaNutrición básica
Nutrición básica
 
Contadiniperscelta ceriani
Contadiniperscelta cerianiContadiniperscelta ceriani
Contadiniperscelta ceriani
 

Similar a Axis 2.0 and WS-I standards

WALA Tutorial at PLDI 2010
WALA Tutorial at PLDI 2010WALA Tutorial at PLDI 2010
WALA Tutorial at PLDI 2010Julian Dolby
 
História da administração faculdade shalom
História da administração   faculdade shalomHistória da administração   faculdade shalom
História da administração faculdade shalomPUC Minas
 
Critical thinking rubric
Critical thinking rubricCritical thinking rubric
Critical thinking rubricTimothy Welsh
 
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)Dimitris Psounis
 
Intergrating OER in Educational Practice: Practitioner Stories
Intergrating OER in Educational Practice: Practitioner StoriesIntergrating OER in Educational Practice: Practitioner Stories
Intergrating OER in Educational Practice: Practitioner StoriesShironica Karunanayaka
 
2013 06 04 design handbook edited
2013 06 04 design handbook edited2013 06 04 design handbook edited
2013 06 04 design handbook editedshu sheng ong
 
Curso contra baixo
Curso contra baixoCurso contra baixo
Curso contra baixoJeziel Lago
 
Apostila contrabaixo
Apostila contrabaixoApostila contrabaixo
Apostila contrabaixofgoncalves51
 
Rocket Profile (Pan-Africa)
Rocket Profile (Pan-Africa)Rocket Profile (Pan-Africa)
Rocket Profile (Pan-Africa)Diana Muchoki
 
What Is Social Media
What Is Social MediaWhat Is Social Media
What Is Social MediaHAL
 
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...Alba Santa
 
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.  HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS. King's College London
 
New Year. Healthy Choices.
New Year. Healthy Choices.New Year. Healthy Choices.
New Year. Healthy Choices.Isabel Tuna
 

Similar a Axis 2.0 and WS-I standards (20)

WALA Tutorial at PLDI 2010
WALA Tutorial at PLDI 2010WALA Tutorial at PLDI 2010
WALA Tutorial at PLDI 2010
 
História da administração faculdade shalom
História da administração   faculdade shalomHistória da administração   faculdade shalom
História da administração faculdade shalom
 
Vanilla creme brulee
Vanilla creme bruleeVanilla creme brulee
Vanilla creme brulee
 
Allen
Allen Allen
Allen
 
Critical thinking rubric
Critical thinking rubricCritical thinking rubric
Critical thinking rubric
 
Victoria sponge
Victoria spongeVictoria sponge
Victoria sponge
 
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)
ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ)
 
Intergrating OER in Educational Practice: Practitioner Stories
Intergrating OER in Educational Practice: Practitioner StoriesIntergrating OER in Educational Practice: Practitioner Stories
Intergrating OER in Educational Practice: Practitioner Stories
 
Que es la ingenieria
Que es la ingenieriaQue es la ingenieria
Que es la ingenieria
 
2013 06 04 design handbook edited
2013 06 04 design handbook edited2013 06 04 design handbook edited
2013 06 04 design handbook edited
 
Curso contra baixo
Curso contra baixoCurso contra baixo
Curso contra baixo
 
Apostila contrabaixo
Apostila contrabaixoApostila contrabaixo
Apostila contrabaixo
 
Rocket Profile (Pan-Africa)
Rocket Profile (Pan-Africa)Rocket Profile (Pan-Africa)
Rocket Profile (Pan-Africa)
 
Pan au chocolate
Pan au chocolatePan au chocolate
Pan au chocolate
 
What Is Social Media
What Is Social MediaWhat Is Social Media
What Is Social Media
 
Camino orar7dias
Camino orar7diasCamino orar7dias
Camino orar7dias
 
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...
EDUTEC-e: "Innovando en la Educación para la empleabilidad y el desarrollo de...
 
Macaroons
MacaroonsMacaroons
Macaroons
 
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.  HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.
HOW TO TEACH SCIENCE IN 1-TO-1 PRIMARY SCHOOLS.
 
New Year. Healthy Choices.
New Year. Healthy Choices.New Year. Healthy Choices.
New Year. Healthy Choices.
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Axis 2.0 and WS-I standards

  • 2. WS-I - Axis 2.0 !" # $% & '( ) * ! , ! !& + !& */ & . * 0 & ) 12 2 . # # 3! 4 / ((( 5 ! /
  • 3. WS-I - Axis 2.0 ) ,! #0! * ! ! 6 7 ( ! ! Web Services Description Language (WSDL) 8 3 )6 , ! 9
  • 4. WS-I - Axis 2.0 ! 6 "# ( 3 ! # ( " ! 9 / ( ' * ,*! ' (! ) (() : (& $ ! ! , ! &3 ! 3* * '& & $ * ' & "# &' ) (! ) )7-$ 3( , , "# % & ! # ! / # # )# & ) '# ! * ) + (* & + # +# * -.)& 0 0 7.& - &0 &(* "# + (
  • 5. WS-I - Axis 2.0 *! # 1 ! %# ) ' (( + ?3 3 !, / + #+ ! !,; < 8 = 7 . ! & + ' # ' ' 7 .& # ( + ( < 8% * ' ( * "# + & ' -> ' ( ! ' ?8& # # * / / / ( + ' * ' ' ) #+ & & # ' ( (! ( & '# ' ( ' #+ # * %
  • 6. WS-I - Axis 2.0 (? 7 / "# '& & # ( +! + ! # # @ ( * "# , -* ) # .* > , # !/ / & ( & ! ! & 3 ) ( ! /3 ! * +/ * & # + 0* 0 !/ ! / # ) # * # ) ! 2 ! * "# &! # ! # )# 6 ! 3 ! (! ( & %# * # ' ) + # ( & & 1 ) ' & ' * * * & %# ' ) (! ( & * , ! "# ' & # )& # 2 ' (
  • 7. WS-I - Axis 2.0 7 1' "# ' ) ( !& ! )& ! ! & ' & "# & ( " !# ) ! !* - & ! & 7 5 ! # & # ( # &# ! (% ) & & )& + ! (% ! ' * & )& ! + ! ( ( 3 # # ) +/ ( #& ( * "# ' % / * .! & A ! ! 7 & B <! 9 *! 7 ) % * ( & % & & # &% & + # 1 ) C # + ! &+
  • 8. WS-I - Axis 2.0 . - D* ! $ 9 - / !6
  • 9. WS-I - Axis 2.0 !
  • 10. WS-I - Axis 2.0 %0$ . 3 !,#EE((( ( % ! "# (! ' & ) ( ! ' / E. 3 E$ . 3 % ! ' # 45 ' -*-% & %& # & ' % ' ( '# ! ' # #! ( ' % ! ' ! &+ ! ! +
  • 11. WS-I - Axis 2.0 7 . "# & & + 6 7) 5)& ! ! ! ,8 & 4 & * # & + 9 3 +4 "" : )( "# 0 ! ' "# +' ) ' ( ( , ' ( ! &! ## 3 ' '
  • 12. WS-I - Axis 2.0 ! 7 .0 " ! F 6 + ' ) 5 & & & "" (! & ; + & & (! ( + & +! &( ) (! )
  • 13. WS-I - Axis 2.0 7 . ''. 1 - D* ! POST /WebCalculator/Calculator.asmx HTTP/1.1 Content-Type: text/xml SOAPAction: “http://tempuri.org/Add” Content-Length: 386 <?xml version=“1.0”?> <soap:Envelope ...> ... </soap:Envelope>
  • 14. WS-I - Axis 2.0 7 . / !* ! * SOAP Message The complete SOAP message Headers Protocol binding headers SOAP Envelope <Envelope> encloses payload SOAP Header Headers SOAP Body Message Name & Data <Header> encloses headers Individual headers <Body> contains SOAP message name XML-encoded SOAP message name & data
  • 15. WS-I - Axis 2.0 A Sample SOAP Request POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "Some-URI“ <SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV: encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • 16. WS-I - Axis 2.0 7 . - ,6 HTTP/1.1 200 OK Content-Type: text/xml; charset="utf-8" Content-Length: nnnn <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:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • 17. WS-I - Axis 2.0 7 . *! HTTP/1.1 500 Internal Server Error Content-Type: text/xml; charset="utf-8" Content-Length: nnnn <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode> SOAP-ENV: MustUnderstand </faultcode> <faultstring>SOAP Must Understand Error </faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • 18. WS-I - Axis 2.0 7 . 5)& * ! 6 "" ! * ) + HTTPS X.509 certificates &! <4 # " ! !& ! = &' & & + "+ ! ' # #( # / ! /& & ! +
  • 19. WS-I - Axis 2.0 ?8 % ! ) #( ' 1. Service interface definition – 2. Service implementation definition – & #+ Abstract semantics for Web Service Concrete end points and network addresses where Web Service can be invoked & ( +) ' &'+ )3 ) * "# +! ! &# ) # > '# ! # & ) '& )' + 4 '# # ) ( * ) # # )& ' & + * "# % ' # & #
  • 21. WSDL WSDL Schema Interface <definitions> • <definitions> are root node of WSDL • <import> allows other entities for inclusion • <types> are data definitions - xsd <import> • <message> defines parameters of a Web Service function <types> • <portType> defines input and output operations <message> <portType> <binding> • <binding> specifies how each message is sent over the wire
  • 22. WSDL WSDL Schema Implementation • <service> specifies details about the implementation • <port> contains the address itself <definitions> <import> <service> <port>
  • 23. WSDL Elements Open – allows for other namespaces and thus highly extensible Ability to import other schemas & WSDL Provides “recipe” for Web Services Provides both interface and implementation details
  • 25. WS-I - Axis 2.0 !/ 0! * ! # ( ? # '# # 1 # ) (( & ) + # 1 ) ' ! ! ' 4 # & ' # (( % & & '& , & &) + # ! ! ' % ! ! # # % &! ( ' ( # 1 * ) * "#
  • 26. WS-I - Axis 2.0 / %) # ! ! .7B ,, 7 % ) & '& , & ) # ( ! & & ) & & &@ ! & ) + & & ) $ & $: ( A & B B ) ( @ & # +! 3 ( & &
  • 27. WS-I - Axis 2.0 !, # ) , ! B & ! 3 ! 3 !, # G ! H'7 ) 'I 7 >J K ( ,, K K >$%0 " !, # ) ! ! 6 L 5L , ! >$%0 " ! 6 !, # ' & ,6! 3 !! ,5 ! 6 !, # 0 ' 3 ! !* /! & ! !! ! ,2 G ! !,#EE # ! ! # E E E ! & ( ( !, # " ( !, 6 !,#EE ! ! # ( ! / /! # # (!+( & 3 # E L , 3 E E E 6 @ =M M! L ! ( 8 !* ! ! / / !& ( ( / * ! , ! *! ,*! # # # ? "( ) * '& ! + )& + & ) #
  • 28. WS-I - Axis 2.0 B- 1 (! 6 / * *6 (! 6 / * *6 (! 6 / * *6 C ! & & ) & & C # + & C & ) $ & $: & B B !! , , A # A (A D ( ! E $ ! < (! * < & # ,< & # & &$% ( E $ & & &@ E $ , + & $%! ) & D ( E$ + &$! & & ) ( ! D ( E$ ( $ ( @ ( A &$
  • 29. WS-I - Axis 2.0 > .7B ( ! ) 7 # /. 9 / " ! 3 3 (! * & (! 6 / * *6 A C ! & & ) @ ! & ) ( @ E A * $ $A * D) ( $ ( D) -F A $ ) A B B 1 , 6 5 ,5 ! 6
  • 30. WS-I - Axis 2.0 & # # # # # % # # (!+ G & * ! 3 3 (! * & ! & & ) @ ! A ! ) ( A ! & ) @ ) A B ! & ) @ #* E A B ! & ) D) ( @ ) ) ( A B ! & ) D) ( ) ( @ #* ) ( E ) ( AB B & % # & && 3& & 3
  • 31. WS-I - Axis 2.0 D # D /% # (!& # ) / .*/ ' (& & ) ! + & # # + '& & + # / .*/ ' (& & ( ,, K K >$%0 K " 3K H ! + / & E$ $ *6 + ! 6$ E$ & E$ * ! # * / .* ! + & ( * G ! + $I & < "# / ! K >$%0 K , 5 " 3 ! ( # + ( ! # *6 ' & # # !& # # !+ " # # #! ! %'" ( # ! < & ,J J < / . ,< & # KK ( 3 * ) G # & # *6 ' * & H'7 ) 'I 7 >J K H'7 ) 'I 7 >J K ( + ') # &2 ' *6 ' * & & # ,, K / .*/ % (& #
  • 32. WS-I - Axis 2.0 ? , 6 / C / ! /! H ( E$ & & $ I H ! I "# (+' % # # + #& & H< ! I H, ! =M ) MJ H ! =M 6 MJ H /=M / , , -.) H< ! I H< I HE, /- !J MEJ
  • 33. WS-I - Axis 2.0 ) !/ "# / ! (! ( & & % # # ' & 3& #, & 3 # ' & */ ' * "# (& & # (!& & & ' ) ) '# '# & & &* ?" 4 D= */ (& & & &* & ! + # & + ) 6 ) /. ( ! ' + * ! ! # # ' & #
  • 34. WS-I - Axis 2.0 ?3 3 ( ! 6 3, 3 / 6 %# / & + '! ' + ( ' , ! '( + # ! ! '( + # ! ' + 1 ) * & & ( & & ' # ! * & & # ' #& * #( # ! % #
  • 35. WS-I - Axis 2.0 , 3 6 / - !! 8 3 !
  • 36. WS-I - Axis 2.0 G *, / "# ( + ( + # & & & & + # ! ' 7 )* ! ( 9 9 ! H 7 )I ! H =M 6 ************************ H< I H =M 6 *********************** H< I H< 7 )I ! & ( MJ MJ ! +() ! & & & # ' *" & # #( + # % /.# #
  • 37. WS-I - Axis 2.0 /' %. ! - * 6 "# ( + ( + # & +3 # # ! & & * + * ?" 4 D= */ (& & ' *6 *6 ) ( ) & # /. ! +& + & ( ) * # ?8 # ' & # ?" 4 D= (+ (! / ! & & ! % &' & # ' * / *! ! & + */ (& * & # # ' & #(
  • 38. WS-I - Axis 2.0 /' %. ! - * 6 "# ( + ( + # & +3 # # ! & & * + * ?" 4 D= */ (& & ' *6 *6 ) ( ) & # /. ! +& + & ( ) * # ?8 # ' & # ?" 4 D= (+ (! / ! & & ! % &' & # ' * / *! ! & + */ (& * & # # ' & #(
  • 39. WS-I - Axis 2.0 ) ! ! % /.# ! ,, )& 7 # =& # & ) # ! +# & )! ! )# N ! ! /3 ' # ?8 * & + # '& & 3& * # ) 3& # !, ' ( # % # * )& ' * & G ! /) /. ( # ' & ( 3 # 3 * , 3& & % * & % )& ' & # ' & ) !& ! 4 ? !) & ( # ' '# ( /. ) . % */ (& *
  • 40. WS-I - Axis 2.0 , #C ? 3* !) %G ! 7,! !G 7 # ' * "# & + '# / . + ) % ' & & & # (! < & & # ') ! & , I ) **L (! L & & * .6 " ! * 5)% ! + & )! & ) ) & / . (! L & ' ( # ' & (( #) # 2 L ,! ) ! % ) # # + "# ' & * & * & 3& ) # # #& & (( M % )# + ! # * "# 2 2& ' # # # 2 2& & ' # # 2 2& % # ' ! / .* 4 % ) + & ! ' # +
  • 41. WS-I - Axis 2.0 , #G ! 0! 3 0 ! "# # # #+ ( ! ) & (! ( & # / . +) # 2 2 I "# # # & * .6 ) **L (! L & ) 3 ) !) &! # ' ' # ') ' ' , & & / . (! L & # ( ( & & %) ' ) % # ) ' & * ' ' ! & * & ' # 3& % * "# & + # 3& ! & ' +& # ( # (! ( & & * ' ) %# *4 % # '
  • 42. WS-I - Axis 2.0 , I #G & * .6 /. /. /. 1 ) /. (! & (! & (! & * ?# (! & ! /) ! % ) **L (! L & ) & / . (! L & ) ) E ) *? # ) *? # ( $ & $A & ) *? # * & ) / . (! & ( 1 ) E ( A ) ! ) A E )* # 1 ) A
  • 43. WS-I - Axis 2.0 > * ! ) & / ( ( + # & * 3 ' ( # & # # ( ( +# # & & & %# / %# + 3 !# ! / ) # & 3 ## ! ' # & ) & ) && ( & ) / #! N * ! ( / * /.# # ( # ( ! &+ ! ) ' ' & # ( / ) )* % # #( # #
  • 44. WS-I - Axis 2.0 !/ , (! # & # / & # ! & & ) (! & & / @ ! & (! ) & & @ B ! &4 ) ! 3 < < # ! & # < < ( # ) 4 ! * D"4 D>?A B B & & & /( &! & ! / # '& & , / =) @ &
  • 45. WS-I - Axis 2.0 D # ) ) ) & '# ) 3( # * & '# ) 3( # , ! *#' *, ! 9 ! !! #' ! 9 ! !! ! !3 : ! ! !' # !! 3 # / # & ) 6! / 3 ( / *! # '& & ! !3 ( *, ! 9 ! !! ! /( (! / !/ 3 ( /( ! ! /& #
  • 46. WS-I - Axis 2.0 . "# ! '! # # & * ! # 4 ) ' & + / .% ( & + )! ! ) ( ' +, & & & '# & * 4 ! ' ( & # ( 4 )3 # + ( ! # ' & / ) # # # # & ! # ) / ) * &* * & & '! # '
  • 47. WS-I - Axis 2.0 # & # & 3( # •= % # 3 # # # ! •"# # 3 # # # ! = # # •D /%# '# # & & & •4 # ! ' # # & # %# •= & % & + &# 3 # # # ! & '# ! % # # '& # & / ) ' * & # *4 ' ! %# & & 3 %/ ! ' # ! # # &* & & 3 * ' ' # ( 1 ) 3 * * ,
  • 48. WS-I - Axis 2.0 '6 , 3. "# + # & ' * "# ' + ! '! # ' (! ( & * + ! '! # , / .*/ * "# (& %# & '# ! # ' ' # # / ) # -* 7& & # ! .* ! ! # G . & &# ! ( ( 7, ! = ( ! # # 3 # + (% & & . %) ! ! # # + (% # # # ! '# * 4 (! & # )# # & &# * ! & %# ) # ' # & ) ' '! (%# +( *
  • 49. WS-I - Axis 2.0 . , H# H H< # , H# H H< # 3 H# H H< # -* ! & ( E$ (! O & & $ & E$ * ! # * / *# & * (! & ! E$ ! -$! = E$ ) $ I # ) # # < &I 8 ! & ( E$ (! O & & $ & E$ * ! # * / *# & * (! & ! E$ ! -$! # ) # # E$ ) $ I < &I & ( E$ (! O & & . $ & E$ * ! # * / *# ! E$ ! -$ ' E$ (! O # ) # & & $I < &I & * (! & & $ I & $ I &.$ I
  • 50. WS-I - Axis 2.0 3 ! H# & ( E$ (! O & & 0 $ & E$ * ! # * / *# H ! E$ ! -$ ' E$ (! O # ) # & & .$ I < H< # &I & * (! & 3 H# & ( E$ (! O & & P & E$ * ! # * / *# & * (! $ & H ! E$ ! -$ ' E$ (! O # ) # & & -$ ' E$ (! O & H< # &I &0$ I & PI $ & .$ I <
  • 51. WS-I - Axis 2.0 ( =& (!+ & & & '! # * "# / .*/ * (& ! # & & & & ) ( # / ) # & & "# ' & & # ') + ! '' & -* 4 =& .* ) =& 0* 4 = ) =& & P ) = ) =& * & '! # # # ' '# & * / ., ' & )& ' !%' &
  • 52. WS-I - Axis 2.0 !/ * 1 * !* ! $ * (
  • 53. WS-I - Axis 2.0 * ) 3/ ! * O * P (! ( ) */ ' # & & (& & & + # & ) # ( (! /( ) % & & # ( # ') ( ) */ * = % 2 & 3 # + & (& & ! ' ') & & ( ) */ & (& # / (! ( ) % # # ) & & &# & ( ) ( % ) # # , & # ( ) (! ( & & &+ ? ! ) & &
  • 54. WS-I - Axis 2.0 . -* "# ' & & 4 &( (! ?/ # ') # * ! # * / .* * * ! # * / .*# & * ! & & 4 ) ) ! &4 ) < < # + ' ) ( ) & & / ., ' & & & / & (! ( & @ ! 3 ! ! +' ( # / ') /( ') / E( / # / =) @ & / /* ') / A
  • 55. WS-I - Axis 2.0 4 ) E 4 ') < < ( # ) ) E4 * & ' ) < < # ) 3 ') /* <! < ) + (* ) *! & T "# ) 4 ! B B /* ! +4 D 4 D7O ? ) * S & : -: T A ) U # ') / ! +4 D 4 D7O ? ( * ( D"4 D>?A ) 7?O T: 7?O >D"O Q?R A >D"O Q?R% ) A ) A
  • 56. WS-I - Axis 2.0 ( ) )# & # &# & ! & # ' )% & # # /? * "# + ) # ! + ! & ' & , 4 ! * D"4 D>?, 7 # & 4 ! * > ?D , + ' * # !) # / ) % 4 ! * 5 ", ( # # & # 3 ) * '& , & "# ! & ) @ ! ' ) & & 3( # % ) %)! % & * "# ) && ) #) & ) ) # ( * ( '# ) * * # ' !# ( %# # ! ! ) 4 D 4 D7O ? >"7 4 D7O ? >D"O ?O =4 D B & # 7?O >D"O Q?R E $ ( 7?O >D"O Q?R E $ ) ?O ?=4 E $ ) O $ A ( ( ) $ A ) $ A %
  • 57. WS-I - Axis 2.0 ( !! */ ! / / *! ! & & ) ) ) & / & (! ( & ) @ ! &4 ) ! 3 /( / # / =) @ & < < # ) ! ! +' ( # ') / ') / ') / E( /* ') / A 4 ) E 4 ') /* ! + >"7 4 D7O ? 7?O >D"O Q?R A < < ( # ) ) E4 * & ' ) * S & : -: T A ) ) U < < 3 # ') ') /* ! + >"7 4 D7O ? 7?O >D"O Q?R% ) A <! < ) + (* ) *! & T "# ) ( ) T: ) A ) 4 ! * D"4 D>?A B B
  • 58. WS-I - Axis 2.0 * 0 , # ) ( !! ) ! & &! & ! % % ) # # & '# )# ! ! +' % & ) # ! % * "# ' % ! & 1 ) # ) ! # & & ) )( )* & 3 # # & ) & # + 1 ) ( # + (% # + ( & ( * "# ( ) (! ( & & & ! + # + ( & & & + ( # & ) ( ! * # ( % # ( ) (! ( & & & ! &4 * ' 3 # / . ') & ( )% & # ( ) (! ( & & & *= ) ! ! % ) & & ( ) (! ( & & & # ,
  • 59. WS-I - Axis 2.0 ! & & ) ) ) (! ( & & )% ) & @ ! ' & >D" O ?D" E $ ) $ A ! ' & "4 ? " O = " E $+ + (( $ A ! ' & =4 ?O >==4 E $ ! *! $ A ! & ) ') / ') /% / ) / & ) # & / =) @ & < < & ) ) + (* ) *! & $ # , ( ) $A & ) ') /% D 4 4 D7O ? 7?O >D"O Q?R A ) ') /% >"7 4 D7O ? 7?O >D"O Q?R A B ! ) ') / ') /% 3+ @ 4 ) E 4 ') /* ! +3 +A ' ) EE )&@ & ') /* ! +3 + 4 % * & '$ $ A B B ) K
  • 60. WS-I - Axis 2.0 ! & ) D ' / + ! / ! # / =) @ & + (* ) *! & $ # D ' : / +$ ! A B ! & ) & )! ! @ < ) < # # ! &+ )! ! ) '& A B ! & ) ! & & + & +! & + !+ % / ! / ! # / =) @ & < < ') ) ) # ! ! &+ V B ! & ) # ) ') / ') / # / =) @ & < < & ) ! # 2 & & # & ) '# < ) < ' & +@ (! & = ( ' ( E (! & = ( "4 ? " O = "A
  • 61. WS-I - Axis 2.0 =& ) =& E =& >D"O ?O =4 D ?O ?=4 : ' ( *' ( =4 ?O >==4 A ' V ) =&* / @ ) =&* D =& A B ! ! !E ! A ! !* ! +4 D 4 D7O ? 7?O >D"O Q?R% ') /* ! +4 D 4 D7O ? 7?O >D"O Q?R * ! !* ! + >"7 4 D7O ? 7?O >D"O Q?R% ') /* ! + >"7 4 D7O ? 7?O >D"O Q?R * < < ' & ! !* =& ) ! ) ( ) =& % >D" O ?D" A B # 4 ?/ ! @ < ' # < / ! 26 ! &) & ( & < < + (* ) *! & $ ) '& V ? $: * A B BB : A A
  • 62. WS-I - Axis 2.0 ! /! * H( ) & ( E$ ) & E$ * ! # * / .* H ! I ) # ( H4 =& I H# & ( E$ ( 4 & E$ * ! # * / .* H ! E$ # " ! ' E$ 5 H< # &I H< =& I 4 H )=& I H# & ( E$ ) & E$ * ! # * / .* H ! E$ # H< # &I H< ) =& I H< ( )I & )$ & (! *( ) * 1 * & & ) ) ( ) H< )$ &I ! ) &$ (! *( ) * 1 *4 ( & & ) $ ' E$ 1 > 4 ) 5 ! # $I < (! *( & )$ I < ) &$ )* 1 * ) & ) I ) ! # $ &$ I ) &$ I
  • 63. WS-I - Axis 2.0 ? , 6 / > / / /! * D + & & ?" 4 D=) ( ) */ ' & (& & * "# % ) & & ?" 4 D= ( ) */ & (& ) ) 4 ( ) D ( + % '& , & ! # + * & )* & & ) &* & ) &* & W4 ' ' ( # & & ) *( * & # & + &! & ! + % ( # W4 ' & )
  • 64. WS-I - Axis 2.0 4 # ( ) & # + (% & '& # ! & , -* 7 # ! < & ,J J < / .< ,< & # KK * .* & 3 # !! ! ' !( , *, (, / ! ! 9 3 * , ( 0* "+ $ ( $ ) ! ( $ / .$ ! %# & ! ) # ( & ! &* P "# & 3 * # * ! 3% ! /! *& ( 3 * ) *! * # *! * #' * !! / *! / / / FD * > // * K & ( ( , *, (, / (! ,% * N & * *! * 3 ! ,% ( *& 9 // XD % ) & * + & # ( ) $ ) & )$ & ) '& * )& + J "# * G ) Q *( ! ! 0 / /) * ! ! ! , !, ! ( - D* ! $ C-0 ? ,! 7 . ! $ ? ,! ( (
  • 65. WS-I - Axis 2.0 ) $ ! .0 9 / " %$ 9 / 0 ! # 6 ) ) %# ( + # ) & 3 &3 3 # ) & ) + # %# ! & ! & 3) & ) + + ') & %+ # ) *4 # '+ # ) % ) + ! * "# ' % # '+ # ) # ! *
  • 66. WS-I - Axis 2.0 '6 # ) , !/ ) !* / 0 ? 3 * !) ! !* !
  • 67. WS-I - Axis 2.0 #0 !, # ) ! 9 / $ ) !, # ) ! 7 > & 8 , < !! ! 6* 9 / / 6 3! O !* ! !3 ! , 6 O ! 3 ! *! <0 & ( 7 ! OPP ! ! ! 3! 7 . !7 > ! & ) ?&( + @ = +' E = + * = +A D ( ! (D E ' * D ( ! $ ! < * ! #* # ,< ?&( ( # E ' * ?&( $ # $ (D A % ?&( & E' * ) ?&( $ & $ (D A ) % & * "/$ & % ' ) & (+ )& $A ( # * #& & A ) ) ( # A B 6 0 P ! < / .$ $ -$A %
  • 68. WS-I - Axis 2.0 !, # $ 3 9 /! & ( ! ! ! ! O, , ! / 6 P 5 ! 7,! !! !! ) !' 5 !7,! ! , , ! * ! / !>.- O> . !- 3 P& 7 . ! & ! , ! !& & ! 3/ ! * ! 3 ! ! ' 3 ( / ,, ! ( (( ! ! 7,! 5 ! 3 ! # & E < < ! 6 ! ! E ! A < < ? ! * " ? ! ' $ ! < *K *-,J J < / .< # ,< -.X *K K K < < ! * $ , # $A ) < < ! * ! ! A & A < + & $A
  • 69. WS-I - Axis 2.0 !, # * ! ! .03 .0 ! , / & /! ?&( + (* ) *! ) # 9 / 9 * ! !/ ! E * & A (! & H , # ! / (& , E$ ! < * ! # * # ,< H ) I & "# (+' & H< ) I H< , # ! I + % & & # '& & < / .< $ / I 9 / , A )! , ) (
  • 70. WS-I - Axis 2.0 D , # * ') & ) # # ) 4' + % ! 3 &3 3 &' + )& & & ) / ( ! ( * ( ( # & + # ) ' + # * # ) # '& & YD ( ! & + # ) ) ( # ## % ?&( &( A , & 3( ! ) ! 6* * ! , ! ( ! & E & )& & % > $ ! < & ,J J < / .< # ,< & # KK < + * YD ( $ ! < * ! # * # ,< / % ( * ! /! (# ?8 & %)& )& $ & &A % < / .$$ # $% % + ( & ! + & % ( ! A
  • 71. WS-I - Axis 2.0 O - 4 ( # 4 # # C! + / " $ 9 / OPP 3 ) ? ( ' (! ( & % # '& & !# '& & & E & ! ! E ! A ! * " ? ! ' $ ! < *K *-,J J < / .< # ,< -.X *K K K ! * $ , # $A ) * ! ! A " %$ 9 / + # )( + # ) + ! !0 ) A $A # 4 "# * ' %) , -% # ) , < + % +( !P
  • 72. WS-I - Axis 2.0 < < & 3 6 & / & 3 & 3E & & ! & ) + (* ) *! & ( /* ? &! (! E ) A & B ! & ) =) & + (* *! ( B ! & ) ? ?/ *! 3 " A B ! & ) (! & (! E ) A R & BA / * /* ! @ & 3 @ & /( 5 +* = /( ? &! * @ / @ ?&( A / @ A
  • 73. WS-I - Axis 2.0 < < 3 # * D 5& 3 + % & 3A & + (* ) *! & $ 4 3 # $A /E K A < < &+ ) & # ! % &! & ! +) < < #% # ! /. & & '< & 3 # + ) +< & % (! ( & & 3 & # +) %< + <( ) ! 7>4 #& V (! & @ "# * & ! -K KA K / ::A ' /I -K @ # / =) $ & "( ) $A B B
  • 74. WS-I - Axis 2.0 # C! + / 0 %7 6 >. O & E & ! ! E ! A ! * " ? ! ' ,! ! ! OM* #*, ! MP: * ! ! A 3 /! O /! OPP A $ ! < *K *-,J J < / .< # ,< -.X *K K K !. 6 8 OPP: < + $A
  • 75. WS-I - Axis 2.0 # C! + / 0 %7 6 >. O "# 4& 3 0% 3 ! // ( # 0 #( !. # ) ( ) # & + ! %# & ' + ' /( ! ! # % *! OPP # )& 3 & ! ! 3 # !0 # & E & A ! ! E ! A ! * " ? ! ' $ ! < *K *-,J J < / .< # ,< -.X *K K K ,! ! ! OM* #*, ! MP: * ! ! A - *! O !. 6 8 OPP: 3 ) ( # '& & < + ) !- * ( , $A
  • 76. WS-I - Axis 2.0
  • 77. Building Web Services the REST Way What is REST? REST is a term coined by Roy Fielding in his Ph.D. dissertation [1] to describe an architecture style of networked systems. REST is an acronym standing for Representational State Transfer. Here is Roy Fielding's explanation of the meaning of Representational State Transfer: "Representational State Transfer is intended to evoke an image of how a welldesigned Web application behaves: a network of web pages (a virtual statemachine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use."
  • 78. Rest REST uses the following standards: HTTP URL XML/HTML/GIF/JPEG/etc (Resource Representations) text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
  • 79. Rest – A sample Illustration Parts Depot Web Services Parts Depot, Inc (fictitious company) has deployed some web services to enable its customers to: get a list of parts get detailed information about a particular part submit a Purchase Order (PO) Let's consider how each of these services are implemented in a RESTful fashion.
  • 80. Rest Get Parts List The web service makes available a URL to a parts list resource. For example, a client would use this URL to get the parts list: http://www.parts-depot.com/parts Note that "how" the web service generates the parts list is completely transparent to the client. All the client knows is that if he/she submits the above URL then a document containing the list of parts is returned. Since the implementation is transparent to clients, Parts Depot is free to modify the underlying implementation of this resource without impacting clients. This is loose coupling.
  • 81. Rest Here's the document that the client receives: <?xml version="1.0"?> <p:Parts xmlns:p="http://www.parts-depot.com" xmlns:xlink="http://www.w3.org/1999/xlink"> <Part id="00345" xlink:href="http://www.parts-depot.com/parts/00345"/> <Part id="00346" xlink:href="http://www.parts-depot.com/parts/00346"/> <Part id="00347" xlink:href="http://www.parts-depot.com/parts/00347"/> <Part id="00348" xlink:href="http://www.parts-depot.com/parts/00348"/> </p:Parts> Assume that through content negotiation the service determined that the client wants the representation as XML (for machine-to-machine processing). Note that the parts list has links to get detailed info about each part. This is a key feature of REST. The client transfers from one state to the next by examining and choosing from among the alternative URLs in the response document.
  • 82. Rest Get Detailed Part Data The web service makes available a URL to each part resource. Example, here's how a client requests part 00345: http://www.parts-depot.com/parts/00345 Here's the document that the client receives: <?xml version="1.0"?> <p:Part xmlns:p="http://www.parts-depot.com" xmlns:xlink="http://www.w3.org/1999/xlink"> <Part-ID>00345</Part-ID> <Name>Widget-A</Name> <Specification xlink:href="http://www.partsdepot.com/parts/00345/specification"/> </p:Part> Again observe how this data is linked to still more data - the specification for this part may be found by traversing the hyperlink. Each response document allows the client to drill down to get more detailed information.
  • 83. Rest Submit PO The web service makes available a URL to submit a PO. The client creates a PO instance document which conforms to the PO schema that Parts Depot has designed (and publicized in a WSDL document). The client submits PO.xml as the payload of an HTTP POST. The PO service responds to the HTTP POST with a URL to the submitted PO. Thus, the client can retrieve the PO any time thereafter (to update/edit it). The PO has become a piece of information which is shared between the client and the server. The shared information (PO) is given an address (URL) by the server and is exposed as a Web service.
  • 84. Rest Logical URLs versus Physical URLs A resource is a conceptual entity. A representation is a concrete manifestation of the resource. This URL: http://www.parts-depot.com/parts/00345 is a logical URL, not a physical URL. Thus, there doesn't need to be, for example, a static HTML page for each part. In fact, if there were a million parts then a million static HTML pages would not be a very attractive design. [Implementation detail: Parts Depot could implement the service that gets detailed data about a particular part by employing a Java Servlet which parses the string after the host name, uses the part number to query the parts database, formulate the query results as XML, and then return the XML as the payload of the HTTP response.] As a matter of style URLs should not reveal the implementation technique used. You need to be free to change your implementation without impacting clients or having misleading URLs.
  • 85. Rest REST Web Services Characteristics Here are the characteristics of REST: Client-Server: a pull-based interaction style: consuming components pull representations. Stateless: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server. Cache: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable. Uniform interface: all resources are accessed with a generic interface (e.g., HTTP GET, POST, PUT, DELETE). Named resources - the system is comprised of resources which are named using a URL.
  • 86. Rest Interconnected resource representations - the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another. Layered components - intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc.
  • 87. Rest Principles of REST Web Service Design 1. The key to creating Web Services in a REST network (i.e., the Web) is to identify all of the conceptual entities that you wish to expose as services. Above we saw some examples of resources: parts list, detailed part data, purchase order. 2. Create a URL to each resource. The resources should be nouns, not verbs. For example, do not use this: http://www.parts-depot.com/parts/getPart?id=00345 Note the verb, getPart. Instead, use a noun: http://www.parts-depot.com/parts/00345
  • 88. Rest 3. Categorize your resources according to whether clients can just receive a representation of the resource, or whether clients can modify (add to) the resource. For the former, make those resources accessible using an HTTP GET. For the later, make those resources accessible using HTTP POST, PUT, and/or DELETE. 4. All resources accessible via HTTP GET should be side-effect free. That is, the resource should just return a representation of the resource. Invoking the resource should not result in modifying the resource. 5. No man/woman is an island. Likewise, no representation should be an island. In other words, put hyperlinks within resource representations to enable clients to drill down for more information, and/or to obtain related information.
  • 89. Rest 6. Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more details. 7. Specify the format of response data using a schema (DTD, W3C Schema, RelaxNG, or Schematron). For those services that require a POST or PUT to it, also provide a schema to specify the format of the response. 8. Describe how your services are to be invoked using either a WSDL document, or simply an HTML document.
  • 90. Rest – POX over HTTP import javax.xml.bind.annotation.XmlType; @XmlType public class Product { private String id; private String name; private double price; public Product() { } //Getters and Setters omitted...
  • 91. Rest import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class ProductCatalog { private List<Product> products; public ProductCatalog() { products = new ArrayList<Product>(); Product p = new Product(); p.setId("123"); p.setName("Shirt"); p.setPrice(159.95D); Product p2 = new Product(); p2.setId("456"); p2.setName("Monkey"); p2.setPrice(2500D); products.add(p); products.add(p2); }
  • 92. Rest public List<Product> getProducts() { return products; } public void setProducts(List<Product> products) { this.products = products; } @Override public String toString() { return products.toString(); } }
  • 93. Rest public class SimpleRestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { public SimpleRestServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("DoGet invoked on RESTful service."); ProductCatalog catalog = new ProductCatalog(); Source xmlSource = asXml(catalog); ServletOutputStream out = response.getOutputStream(); response.setContentType("text/xml"); StreamResult st = new StreamResult(out); try {
  • 94. Rest Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(xmlSource, st); } catch (Exception e) { throw new ServletException(e); } System.out.println("All done."); } private static Source asXml(ProductCatalog pc) throws ServletException { System.out.println("Marshalling..."); Source source = null; Document doc = null; try { JAXBContext ctx = JAXBContext.newInstance(ProductCatalog.class);
  • 95. Rest Marshaller m = ctx.createMarshaller(); DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); doc = parser.newDocument(); System.out.println("Products=" + pc); m.marshal(pc, doc); System.out.println("Marshalled catalog to XML."); } catch (JAXBException je) { throw new ServletException(je); } catch (ParserConfigurationException pce) { throw new ServletException(pce); } source = new DOMSource(doc); System.out.println("Returning XML source."); return source; }
  • 99. Rest Developing REST Webservices in MyEclipse – Using JAX-RS 1. Introduction We will outline the process of developing a REST web service, deploying it to the internal MyEclipse Tomcat server and testing it with the REST Web Services Explorer. The REST features in MyEclipse are based on Jersey, which is the reference implementation for JAX-RS, the Java API for RESTful Web Services. We will be creating a simple web service which we will use to maintain a list of customers. MyEclipse also supports developing SOAP web services using JAX-WS; for folks needing to develop and deploy WebSphere JAX-RPC or WebSphere JAXWS web services, please take a look at MyEclipse Blue Edition.
  • 100. Rest System Requirements This tutorial was created with MyEclipse 7.0. If you are using another version of MyEclipse (possibly newer), most of these screens and instructions should still be very similar Creating the REST Web Service Project Invoke the wizard using File > New > Other > MyEclipse > Java Enterprise Projects > Web Service Project. Name the project restdemo and select REST (JAX-RS) from the list of frameworks. Click Next to move to page 2 of the wizard. On this page you can specify the path at which the services will be available, the name of the corresponding JAX-RS servlet and libraries which you wish to add to your project. For this project the defaults are fine, so click Finish to create the project.
  • 101. Rest Instead of creating a new project, you may also add REST capabilities to any existing Java EE 5 Web project. From the project's context menu, select MyEclipse > Add REST Capabilities... Creating the REST Web Service Creating the Customer entity To start, create a simple Customer class with id, name and address fields; this class represents the Customer entity we will be managing with our web service. Use the File > New > Class wizard, put Customer in theName field, com.myeclipseide.ws in the Package field and Finish the wizard. Replace the contents of the generated class with the following code:
  • 102. Rest we will be using XML as the serialization format, i.e. we will send and receive Customer entities from the web service using XML. The @XMLRootElement annotation on the Customer class is a JAXB annotation which allows JAXB to convert this entity from Java to XML and back. It is possible to annotate the fields and methods within the class to customize the serialization, but for our tutorial the JAXB defaults are fine. import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Customer { private int id; private String name; private String address; //write setters and getters …} – Rest refer the Study Material
  • 103. Rest Mapping HTTPMethods to Operations Performed HTTP Method Operations Performed GET Get a resource POST Create a resource and other operations, as it has no defined semantics PUT Create or update a resource DELETE Delete a resource
  • 104. Rest HowDoes Jersey Fit In? Jersey is Sun's production quality reference implementation for JSR 311: JAXRS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM. Jersey also adds additional features not specified by the JSR. The latest version of the JAX—RS API's can be viewed at https://jsr311.dev.java.net/nonav/javadoc/index.html
  • 105. Rest Working with Jersey To successfully run the JAX-RS reference implementation, you need a lot of JARs. It’s probably easiest to put them on your server’s classpath, but you can certainly add them to your WAR’s WEB-INF/lib directory if you like. As of the current release, they are: • activation.jar • asm-3.1.jar • grizzly-servlet-webserver-1.7.3.2.jar• http.jar • jaxb-api.jar • jaxb-impl.jar • jaxb-xjc.jar • jaxws-api.jar• jdom-1.0.jar• jersey.jar• jettison-1.0-RC1.jar• jsr173_api.jar • jsr250-api.jar• jsr311-api.jar• rome-0.9.jar• wadl2java.jar
  • 106. Rest Modifying the web.xml file You need to modify your web.xml file to use the Jersey adapter servlet, much as you would when using JavaServer Faces: <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>ServletAdaptor</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ServletAdaptor</servlet-name> <url-pattern>/resources/*</url-pattern> </servlet-mapping>
  • 107. Rest Creating Hello World with Jersey import javax.ws.rs.Path; import javax.ws.rs.GET; import javax.ws.rs.ProduceMime; /** * Simplest REST web service. */ @Path("/helloRest") public class HelloRest { /** •Retrieves representation of an instance of •HelloRest.java * @return a string with HTML text. */ @GET @ProduceMime("text/html") public String sayHello() { return "<html><body><h1>Hello from REST!</body></h1></html>"; } }
  • 108. Rest Here you create a POJO that is annotated with javax.ws.rs.Path. Its value attribute indicates the path where this resource will be made available. The resource path follows the adapter servlet path, so you will be able to reach an instance of this class at <server>:<port>/<context>/<jersey-servletmapping>/<path-value> By using the JAX-RS @GET annotation, you indicate that the sayHello method is the one you want to respond to HTTP GET requests. Then use the @ProduceMime annotation to indicate the MIME type you want to return on response. Here you use text/html, but you can use any MIME type that makes sense for your application, including text/xml and image/gif.
  • 109. Rest Creating a Single Path for Variable Resources of the Same Type @Path("/products/{id}") public class ProductResource { @Context private UriInfo context; /** Creates a new instance of ProductResource */ public ProductResource() { } @GET @ProduceMime("text/plain") public String getProduct(@PathParam("id") int productId) { switch (productId) { case 1: return "A Shiny New Bike"; case 2: return "Big Wheel"; case 3: return "Taser: Toddler Edition"; default: return "No such product"; } } }
  • 110. Rest Restricting the Structure of Values in a Path Template @Path("products/{id:[a-zA-Z][a-zA-Z_0-9]}”). @Path("/products/{id: d{3}}") - the input should be exactly three digits. URL http:// localhost:8080/restexamples/resources/products/555,
  • 111. Rest Accessing Query Parameters Use the @QueryParam annotation on your method parameter. Optionally, include the @DefaultValue in case the query parameter you’re expecting is not passed. @GET @Produces("text/xml") public String getProducts( @PathParam("id") int productId, @QueryParam("results") @DefaultValue("5") int numResults) { StringBuilder result = new StringBuilder("<products>"); //return the number of results requested for (int i = 0; i < numResults; i++) { result.append("<p>Product " + i + "</p>"); } result.append("</products>"); return result.toString(); }
  • 112. Rest Marshaling a Custom Type to XML in a Response Problem You want your service to provide an XML view of a custom Java type you’ve defined. Hint: @XmlRootElement, and create a JAX-RS service that indicates that it produces XML with the @Produces("application/xml") annotation. shows a basic Java type that your service can automatically marshal to XML using JAXB. Employee.java with JAXB annotations to assist in automatic marshaling package com.soacookbook.rest.xml; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="employee") public class Employee { @XmlElement(name="id") int id; @XmlElement(name="name") String name; }
  • 113. Rest public class EmployeeService { private static Map<Integer, Employee> emps = populateDatabase(); public EmployeeService() { } @GET @Path("{id}") @Produces("application/xml") public Employee getEmployee(@PathParam("id") int empId) { return emps.get(empId); } private static Map<Integer, Employee> populateDatabase(){ Map<Integer, Employee> emps = new HashMap<Integer, Employee>(); Employee e1 = new Employee(); e1.id = 1; e1.name = "Bill Gates"; Employee e2 = new Employee();e2.id = 2;e2.name = "Larry Ellison"; Employee e3 = new Employee();e3.id = 3;e3.name = "Steve Jobs"; emps.put(1, e1); emps.put(2, e2); emps.put(3, e3); return emps;}}
  • 114. Rest Offering Different Representations of the Same Resource Problem You want your service to provide alternate views of the same resource. Discussion A standard browser will pass the MIME types it can handle by passing the HTTP Accept header in its request. A typical request header sent from Firefox looks like this: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 The client is telling the server that it would prefer to get HTML or XHTML, and its next preference is to accept XML. The preferences are indicated not only by the order in which they appear, but with the q parameter, used to specify a relative “quality factor” or how strong the preference is for the given media type on a scale of 0 to 1.
  • 115. Rest import java.io.File; import javax.activation.MimetypesFileTypeMap; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; /** * If we put a @Produces annotation on the class level, * that will be the value matched despite browser preferences * in the Accept header. */ @Path("/duke") @Produces("text/plain") public class DifferentRepresentations { private static final String IMG_PATH = "C:programs/eclipse/workspace/restexamples/WebContent/duke.gif"; Contd…
  • 116. Rest @GET @Produces("text/html") public String doGetAsHtml() { return "<html><h1>Html Duke</h1></html>"; } //notice no override, as this method returns the default @GET public String doGetAsPlainText() { return "Plain Duke"; } @GET @Produces("image/*") public Response doGetAsImage() { File image = new File(IMG_PATH); if (!image.exists()) { throw new WebApplicationException(404); } String type = new MimetypesFileTypeMap().getContentType(image); return Response.ok(image, type).build(); } contd…
  • 117. Rest @GET @Produces("text/xml") public String doGetAsXml() { return "<?xml version='1.0' encoding='utf-8'?>" + "<mascot>Xml Duke</mascot>"; } } //end
  • 118. Rest Creating a Resource Problem You want to provide a way for users to create a RESTful resource in JAX-RS. Solution Use the @POST annotation on a resource method to indicate that it accepts HTTP POST data, and add the entity in the method with the incoming data.
  • 119. Rest @Path("user/{id}") @Singleton public class UserService { private Map<Integer, User> userDatabase; //create fake user database to keep example simple public UserService() { userDatabase = new HashMap<Integer, User>(); } @POST @Consumes("application/xml") public Response postUser(User user) { System.out.println("Post User."); //save to database here... userDatabase.put(user.getId(), user); System.out.println("Posted user: " + user); URI createdUri = UriBuilder.fromPath("user/" + user.getId()).build(user); System.out.println("post: createdUri: " + createdUri); //return a 201 'created' status return Response.created(createdUri).build(); }
  • 120. WS-I - Axis 2.0 G 7 (3 "
  • 121. WS-I - Axis 2.0
  • 122. Learning Objectives Understand the coming Web Services revolution Fundamentals of Web Services
  • 123. Web Services Overview Internet Business Processes Span Companies
  • 124. Web Services Overview Technology Fabric Must Span Companies Too
  • 125. Web Services Overview Possible Solutions Distributed computing Web sites (portals) Web Services
  • 126. Web Services Overview Distributed Computing Client/server model Doesn‘t scale Not secure Distributed object model Components: packaging and interoperability Remoting: remote method invocation COM, CORBA, Java RMI and EJB Not Internet-friendly Interoperability issues: poor/non-existent standards Tightly coupled: still doesn‘t scale
  • 127. Web Services Overview Distributed Computing 3-tier Application Architecture Great way to build scalable Web applications But such applications are silos Integration is an afterthought They can be integrated behind the firewall Even that can be a problem They do not provide a way to integrate across the firewall (i.e. over the Internet)
  • 129. Web Services Overview Portal Limitations No standard way to expose functionality Integration is expensive and error-prone Hard to outsource Not designed to be used outside original scope The problem? HTML is designed for presentation to people Can’t repurpose it in a general, reliable way
  • 130. Web Services Overview What Is a Web Service? The solution? Web Services! A Web Service exposes functionality to a consumer Over the Internet or intranet A programmable URL Functions you can call over the Internet Based on Web standards HTTP, XML, SOAP, WSDL, UDDI, with more to come Can be implemented in any language on any platform Black boxes Component-like, reusable
  • 131. Web Services Overview What Is a Web Service? A Web Service combines the best features of distributed computing and portals and eliminates the worst Provides a mechanism for invoking methods remotely Uses Web standards (e.g. HTTP, XML) to do so
  • 132. Web Services Overview What Is a Web Service? Web Services allow you to interconnect: Different companies Many/any devices Applications Different clients Not just browsers Distribution and integration of application logic Enable the programmable Web Not just the purely interactive Web Web Services are loosely coupled
  • 133. Web Services Overview What is a Web Service? New paradigm for Internet development Deliver applications as services Richer, customer-driven experience Continuous delivery of value/bits Third-generation Internet
  • 134. Web Services Overview Evolution of the Web HTML HTML HTML, XML HTML, XML Generation 1 Static HTML Generation 2 Web Applications Generation 3 Web Services
  • 135. Web Services The Web today How Web services work
  • 136. Web Services The Web Today Purchase courseware Purchased Designed for people to browse
  • 137. Web Services The Web Today Purchase Courseware ? Server to server is a problem
  • 138. Web Services What Are Web Services? Allow applications to communicate across the internet Platform independent Protocol independent Synchronous/asynchronous Statefull/stateless BizTalk® ASP.NET
  • 142. Web Services Register for Course Purchase Courseware Proxy
  • 143. Web Services Overview Application Model Partner Web Service Other Web Services Internet + XML End Users YourCompany.com Application Business Logic Tier Data Access and Storage Tier Other Applications Partner Web Service
  • 144. Web Services Overview Sample Web Services E-commerce: order books, office supplies, other products Track packages: UPS, FedEx Weather Maps Telephone redirection, customizable rules and messages
  • 145. Underlying Technologies XML Is the Glue Connectivity Connect the Web Presentation Browse the Web Connecting Applications Program the Web
  • 146. Underlying Technologies Web Services Stack Directory: Publish & Find Services: UDDI Inspection: Find Services on server: DISCO Description: Formal Service Descriptions: WSDL Wire Format: Service Interactions: SOAP Universal Data Format: XML Ubiquitous Communications: Internet Simple, Open, Broad Industry Support
  • 147. Underlying Technologies Web Services Stack Discovery Directory allows potential clients to locate relevant Web Services UDDI Inspection allows you to locate documents about Web Services located on at a given URL DISCO A Description language defines the format of methods provided by a Web Service WSDL
  • 148. Underlying Technologies Web Services Stack UDDI Link to Discovery Document (XML) http://www.ibuyspy.com/ibuyspy.disco Request Discovery Document DISCO Return Discovery Document (XML) Description WSDL http://www.ibuyspy.com/ibuyspycs/InstantOrder.asmx?wsdl Request Service Description Return Service Description (XML) Wire Format Request Service Return Service Response (XML) SOAP Web Service Web Service Client Inspection UDDI or other directory service Directory http://www.uddi.org Locate a Service
  • 149. Underlying Technologies Web Service Wire Format The Web Service Wire Format specifies how specific messages are exchanged HTTP-GET HTTP-POST SOAP HTTP-GET and HTTP-POST use a minimal HTTP interface to invoke Web Services Limited support for data types SOAP provides a robust HTTP/XML interface Extensive support for data types
  • 150. XML Overview XML Basics XML is designed to represent and transfer structured data In HTML: In XML: XML does not display or transform data XML separates data from formatting and transforming HTML and XML are both derived from SGML In different ways
  • 151. XML Overview XML Syntax XML is composed of tags and attributes Tags can be nested Representing entities, entity properties, and entity hierarchy <ROOT> <Orders OrderID="10643" CustomerID="ALFKI" EmployeeID="6" OrderDate="1997-08-25T00:00:00" RequiredDate="1997-09-22T00:00:00" ShippedDate="1997-09-02T00:00:00" /> </ROOT>
  • 152. XML Overview XML Schemas XML schemas describe the structure of an XML document XML schemas describe the tag and attribute specifications Simple and compound data types XML schemas also describe constraints on the contained text XML schemas and the DTD are mutually exclusive
  • 153. WS-I - Axis 2.0
  • 154. WS-I - Axis 2.0
  • 155. WS-I - Axis 2.0