Вы находитесь на странице: 1из 18

Interview Questions

Day 1
WebServices Topic
o UDDI
o SOAP
o WSDL
o JAX-RPC
o JAX-WS
o JAXB
Defne Web Service?
A web service is a kind o so!ware !"a! is accessib#e on !"e In!erne!$ I! %akes
&se o !"e X'L %essa(in( s)s!e% and o*ers an eas) !o &nders!and+ in!erace
or !"e end &sers$
A Web service is a method of communication between two electronic devices over the World
Wide Web. A Web service is a software function provided at a network address over the web or
the cloud, it is a service that is "always on" as in the concept of utility computing.
W"a! UDDI %eans?
UDDI s!ands or Universa#+ Descri,!ion+ Discover)+ and In!e(ra!ion$ I! is !"e
discover) #a)er in !"e web services ,ro!oco# s!ack$
-.,#ain in brie+ w"a! UDDI is?
UDDI /Universa# Descri,!ion+ Discover)+ and In!e(ra!ion0 ,rovides
conso#ida!ed direc!or) or web services on !"e in!erne!$ C#ien!s &se UDDI !o
fnd web services as ,er !"eir b&siness needs$ I! basica##) "os!s !"e web
services ro% vario&s co%,anies$ In order !o s"are web services+ )o& need !o
,&b#is" i! in UDDI$
SOAP
W"a! is SOAP ?
SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for
exchanging structured information in the implementation of Web Services in computer networks.
It relies on xtensible !arkup "anguage #$!"% for its message format, and usually relies on
other Application "ayer protocols, most notably &ypertext 'ransfer (rotocol #&''(% and Simple
!ail 'ransfer (rotocol #S!'(%, for message negotiation and transmission.
SOAP s!ands or Si%,#e Ob1ec! Access Pro!oco#
SOAP is a si%,#e X'L-based ,ro!oco# !o #e! a,,#ica!ions e.c"an(e inor%a!ion
over 233P$
Soa,+ in i!s c&rren! or%+ is a %e!"od or RPC /Re%o!e Proced&re Ca##s0 over a
ne!work$ I is a#so &sed a wa) !o !ranser doc&%en!s aro&nd as X'L
SOAP a##ows )o& !o (e! aro&nd frewa##s
SOAP is a co%%&nica!ion ,ro!oco#
SOAP is or co%%&nica!ion be!ween a,,#ica!ions
SOAP is a or%a! or sendin( %essa(es
SOAP is desi(ned !o co%%&nica!e via In!erne!
SOAP is ,#a!or% inde,enden!
SOAP is #an(&a(e inde,enden!
SOAP is based on X'L
SOAP is si%,#e and e.!ensib#e
-.a%,#e 'essa(e
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml c!arset"#t$-%
Content-&engt!: '((
SO)P)ction: *!ttp://www.w+.org/',,+/,-/soap-en.elope*

/0xml .ersion"*1.,*01
/soap:2n.elope xmlns:soap"*!ttp://www.w+.org/',,+/,-/soap-en.elope*1
/soap:Hea3er1
//soap:Hea3er1
/soap:4o3y1
/m:5etStockPrice xmlns:m"*!ttp://www.example.org/stock*1
/m:Stock6ame1I47//m:Stock6ame1
//m:5etStockPrice1
//soap:4o3y1
//soap:2n.elope1
W"a! is SOAP4s S)n!a. R&#es?
2ere are so%e i%,or!an! s)n!a. r&#es5
6 A SOAP %essa(e 'US3 be encoded &sin( X'L
6 A SOAP %essa(e 'US3 &se !"e SOAP -nve#o,e na%es,ace
6 A SOAP %essa(e 'US3 &se !"e SOAP -ncodin( na%es,ace
6 A SOAP %essa(e %&s! 7O3 con!ain a D3D reerence
6 A SOAP %essa(e %&s! 7O3 con!ain X'L Processin( Ins!r&c!ions
Ske#e!on SOAP 'essa(e
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>soa,-encodin(:=
8soa,52eader=
$$$
8>soa,52eader=
8soa,5Bod)=
$$$
8soa,5@a&#!=
$$$
8>soa,5@a&#!=
8>soa,5Bod)=
8>soa,5-nve#o,e=
W"a! is SOAP -nve#o,e?
3"e 233P reA&es! bod) con!ains !"e SOAP reA&es! i!se#$ 3"is is wra,,ed in a
SOAP enve#o,e+ w"ic" con!ains %e!ada!a i%,or!an! or &nders!andin( !"e
reA&es!$ 3"e s!r&c!&re is as o##ows5
8SOAP--7B5-nve#o,e
.%#ns5SOAP--7B9:"!!,5>>www$www$or(>soa,>enve#o,e>:
SOAP--7B5encodin(S!)#e9:"!!,5>>www$www$or(>soa,>encodin(>:
=
8C-- SOAP bod) (oes "ere --=
8>SOAP--7B5-nve#o,e=
3"e SOAP enve#o,e is in !"e X'L na%es,ace ,rescribed b) !"e s,ecifca!ion5
"!!,5>>www$www$or(>soa,>enve#o,e>$
3"e enve#o,e %&s! s,eci) "ow !o in!er,re! !"e SOAP bod)$ 3"is is
acco%,#is"ed wi!" !"e SOAP--7B5encodin(S!)#e a!!rib&!e$ 3"e va#&e is a URI
indica!in( a s,ecifca!ion or !"e s!r&c!&re o !"e bod)$
W"a! is SOAP -nve#o,e -#e%en!?
3"e SOAP -nve#o,e e#e%en! is !"e roo! e#e%en! o a SOAP %essa(e$
3"e reA&ired SOAP -nve#o,e e#e%en! is !"e roo! e#e%en! o a SOAP %essa(e$
3"is e#e%en! defnes !"e X'L doc&%en! as a SOAP %essa(e$
-.a%,#e
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>soa,-encodin(:=
$$$
'essa(e inor%a!ion (oes "ere
$$$
8>soa,5-nve#o,e=

W"a! does SOAP 7a%es,ace defnes ?
3"e na%es,ace defnes !"e -nve#o,e as a SOAP -nve#o,e$
I a di*eren! na%es,ace is &sed+ !"e a,,#ica!ion (enera!es an error and
discards !"e %essa(e$
W"ic" Pro!oco# is &sed b) Web service and Web service cons&%er
!o co%%&nica!e wi!" eac" o!"er ?
SOAP is a X'L based 4%essa(e4 !"a! a web service c#ien! can send !o an
ac!&a# web service /D vice versa0$ 3"e reason w") !"is %essa(e is !er%ed as
a 4,ro!oco#4 is beca&se !"e X'L se%an!ics inside !"is %essa(e is based on a
we## know s!andard &nders!ood b) bo!" !"e ac!&a#web service D a## i!s c#ien!s$
W"a! is SOAP 2eader -#e%en!
3"e SOAP 2eader e#e%en! con!ains "eader inor%a!ion$
3"e o,!iona# SOAP 2eader e#e%en! con!ains a,,#ica!ion-s,ecifc inor%a!ion
/#ike a&!"en!ica!ion+ ,a)%en!+ e!c0 abo&! !"e SOAP %essa(e$
I !"e 2eader e#e%en! is ,resen!+ i! %&s! be !"e frs! c"i#d e#e%en! o !"e
-nve#o,e e#e%en!$
7o!e5 A## i%%edia!e c"i#d e#e%en!s o !"e 2eader e#e%en! %&s! be
na%es,ace-A&a#ifed$
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>soa,-encodin(:=
8soa,52eader=
8%53rans .%#ns5%9:"!!,5>>www$www$or(>?<;<>;?>!ransac!ion>:
soa,5%&s!Unders!and9:;:=?EF
8>%53rans=
8>soa,52eader=
$$$
$$$
8>soa,5-nve#o,e=
Describe !"e SOAP ac!or a!!rib&!e?
A SOAP %essa(e %a) !rave# ro% a sender !o a receiver b) ,assin( di*eren!
end,oin!s a#on( !"e %essa(e ,a!"$ 2owever+ no! a## ,ar!s o a SOAP %essa(e
%a) be in!ended or !"e &#!i%a!e end,oin!+ ins!ead+ i! %a) be in!ended or
one or %ore o !"e end,oin!s on !"e %essa(e ,a!"$
3"e SOAP ac!or a!!rib&!e is &sed !o address !"e 2eader e#e%en! !o a s,ecifc
end,oin!$
S)n!a.
soa,5ac!or9:URI:
-.a%,#e
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>>soa,-encodin(:=
8soa,52eader=
8%53rans .%#ns5%9:"!!,5>>www$www$or(>?<;<>;?>!ransac!ion>:
soa,5ac!or9:"!!,5>>www$www$or(>?<;<>;?>a,,%#>:=?EF
8>%53rans=
8>soa,52eader=
$$$
$$$
8>soa,5-nve#o,e=
Describe !"e SOAP %&s!Unders!and a!!rib&!e?
3"e SOAP %&s!Unders!and a!!rib&!e can be &sed !o indica!e w"e!"er a
"eader en!r) is %anda!or) or o,!iona# or !"e reci,ien! !o ,rocess$
I )o& add %&s!Unders!and9:;: !o a c"i#d e#e%en! o !"e 2eader e#e%en! i!
indica!es !"a! !"e receiver ,rocessin( !"e 2eader %&s! reco(niGe !"e
e#e%en!$ I !"e receiver does no! reco(niGe !"e e#e%en! i! wi## ai# w"en
,rocessin( !"e 2eader$
S)n!a.
soa,5%&s!Unders!and9:<H;:
-.a%,#e
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>soa,-encodin(:=
8soa,52eader=
8%53rans .%#ns5%9:"!!,5>>www$www$or(>?<;<>;?>!ransac!ion>:
soa,5%&s!Unders!and9:;:=?EF
8>%53rans=
8>soa,52eader=
$$$
$$$
8>soa,5-nve#o,e=
-.,#ain abo&! Re%o!e ca## ,roced&re?
Re%o!e ca## ,roced&re is considered as a ver) i%,or!an! &nc!ion in SOAP$ In
RCP a &ser /node0 sends a reA&es! !o ano!"er node /server0 w"ere !"e
inor%a!ion is ,rocesses and sent to the user. It immediately sends message across
the network.
An )(* is initiated by the client, which sends a re+uest message to a known remote server to
execute a specified procedure with supplied parameters. 'he remote server sends a response to
the client, and the application continues its process. While the server is processing the call, the
client is blocked #it waits until the server has finished processing before resuming execution%,
unless the client sends an asynchronous re+uest to the server, such as an $&''( call. 'here are
many variations and subtleties in various implementations, resulting in a variety of different
#incompatible% )(* protocols.
W"a! is !"e SOAP bod)?
3"ere is one %ore #a)er o SOAP e#e%en! enc#osin( !"e ac!&a# e#e%en!s o !"e
s,ecia#iGed even! ca#endar reA&es!s$
8SOAP--7B5Bod)=
8C-- User reA&es! code "ere --=
8>SOAP--7B5Bod)=
3"e SOAP bod) c#ear#) %arks !"e se,ara!ion o SOAP %e!ada!a and da!a$
W"a! is SOAP Bod) -#e%en!?
SOAP Bod) e#e%en! con!ains !"e ac!&a# SOAP %essa(e in!ended or !"e
&#!i%a!e end,oin! o !"e %essa(e$
I%%edia!e c"i#d e#e%en!s o !"e SOAP Bod) e#e%en! %a) be na%es,ace-
A&a#ifed$
-.a%,#e
8?.%# version9:;$<:?=
8soa,5-nve#o,e
.%#ns5soa,9:"!!,5>>www$www$or(>?<;<>;?>soa,-enve#o,e:
soa,5encodin(S!)#e9:"!!,5>>www$www$or(>?<;<>;?>soa,-encodin(:=
8soa,5Bod)=
8%5Ie!Price .%#ns5%9:"!!,5>>www$www$or(>?<;<>;?>,rices:=
8%5I!e%=A,,#es
8>%5Ie!Price=
8>soa,5Bod)=
8>soa,5-nve#o,e=
3e## %e abo&! w"a! kinds o inor%a!ion inc#&ded in SOAP "eader?
2eader o SOAP con!ains inor%a!ion #ike !"a!+
;$ In SOAP "eader c#ien! s"o&#d "and#e a&!"en!ica!ion and !ransac!ion$
?$ 3"e SOAP %essa(e s"o&#d ,rocess b) c#ien!$
E$ -ncodin(S!)#e is a#so "as in "eader$
2ow )o& e.,#ain @a&#! -#e%en! o SOAP?
3"e SOAP @a&#! e#e%en! "o#d errors and s!a!&s inor%a!ion or a SOAP
%essa(e$
3"e o,!iona# SOAP @a&#! e#e%en! is &sed !o indica!e error %essa(es$
I a @a&#! e#e%en! is ,resen!+ i! %&s! a,,ear as a c"i#d e#e%en! o !"e Bod)
e#e%en!$ A @a&#! e#e%en! can on#) a,,ear once in a SOAP %essa(e$
3"e SOAP @a&#! e#e%en! "as !"e o##owin( s&b e#e%en!s5
<faultcode> A code or iden!i)in( !"e a&#!
<faultstring> A "&%an readab#e e.,#ana!ion o !"e a&#!
<faultactor> Inor%a!ion abo&! w"o ca&sed !"e a&#! !o "a,,en
<detail> 2o#ds a,,#ica!ion s,ecifc error inor%a!ion re#a!ed !o !"e Bod)
e#e%en!
WSDL
W"a! is WSDL?
WSDL is a doc&%en! wri!!en in X'L$ 3"e doc&%en! describes a Web service$
I! s,ecifes !"e #oca!ion o !"e service and !"e o,era!ions /or %e!"ods0 !"e
service e.,oses$
WSDL s!ands or Web Services Descri,!ion Lan(&a(e
WSDL is wri!!en in X'L
WSDL is an X'L doc&%en!
WSDL is &sed !o describe Web services
WSDL is a#so &sed !o #oca!e Web services
WSDL is no! )e! a WEC s!andard
WSDL Por!s
3"e e#e%en! is !"e %os! i%,or!an! WSDL e#e%en!$ I! describes a web service+
!"e o,era!ions !"a! can be ,eror%ed+ and !"e %essa(es !"a! are invo#ved$
3"e e#e%en! can be co%,ared !o a &nc!ion #ibrar) /or a %od&#e+ or a c#ass0 in
a !radi!iona# ,ro(ra%%in( #an(&a(e$
WSDL 'essa(es
3"e e#e%en! defnes !"e da!a e#e%en!s o an o,era!ion$ -ac" %essa(e can
consis! o one or %ore ,ar!s$ 3"e ,ar!s can be co%,ared !o !"e ,ara%e!ers o
a &nc!ion ca## in a !radi!iona# ,ro(ra%%in( #an(&a(e$
WSDL 3),es
3"e e#e%en! defnes !"e da!a !),e !"a! are &sed b) !"e web service$ @or
%a.i%&% ,#a!or% ne&!ra#i!)+ WSDL &ses X'L Sc"e%a s)n!a. !o defne da!a
!),es$
WSDL Bindin(s
3"e e#e%en! defnes !"e %essa(e or%a! and ,ro!oco# de!ai#s or eac" ,or!$
WSDL Por!s
3"e e#e%en! is !"e %os! i%,or!an! WSDL e#e%en!$ I! defnes a web service+
!"e o,era!ions !"a! can be ,eror%ed+ and !"e %essa(es !"a! are
invo#ved$3"e ,or! defnes !"e connec!ion ,oin! !o a web service$ I! can be
co%,ared !o a &nc!ion #ibrar) /or a %od&#e+ or a c#ass0 in a !radi!iona#
,ro(ra%%in( #an(&a(e$ -ac" o,era!ion can be co%,ared !o a &nc!ion in a
!radi!iona# ,ro(ra%%in( #an(&a(e$
Bindin( !o SOAP
3"e bindin( e#e%en! "as !wo a!!rib&!es - !"e na%e a!!rib&!e and !"e !),e
a!!rib&!e$3"e na%e a!!rib&!e /)o& can &se an) na%e )o& wan!0 defnes !"e
na%e o !"e bindin(+ and !"e !),e a!!rib&!e ,oin!s !o !"e ,or! or !"e bindin(+
in !"is case !"e :(#ossar)3er%s: ,or!$3"e soa,5bindin( e#e%en! "as !wo
a!!rib&!es - !"e s!)#e a!!rib&!e and !"e !rans,or! a!!rib&!e$3"e s!)#e a!!rib&!e
can be :r,c: or :doc&%en!:$ In !"is case we &se doc&%en!$ 3"e !rans,or!
a!!rib&!e defnes !"e SOAP ,ro!oco# !o &se$ In !"is case we &se 233P$3"e
o,era!ion e#e%en! defnes eac" o,era!ion !"a! !"e ,or! e.,oses$@or eac"
o,era!ion !"e corres,ondin( SOAP ac!ion "as !o be defned$ Jo& %&s! a#so
s,eci) "ow !"e in,&! and o&!,&! are encoded$ In !"is case we &se :#i!era#:$
/0xml .ersion"*1.,*01
/3e$initions name"*Stock8#ote*
target6amespace"*!ttp://example.com/stock9#ote.ws3l*
xmlns:tns"*!ttp://example.com/stock9#ote.ws3l*
xmlns:xs31"*!ttp://example.com/stock9#ote.xs3*
xmlns:soap"*!ttp://sc!emas.xmlsoap.org/ws3l/soap/*
xmlns"*!ttp://sc!emas.xmlsoap.org/ws3l/*1
/types1
/sc!ema target6amespace"*!ttp://example.com/stock9#ote.xs3*
xmlns"*!ttp://www.w+.org/',,,/1,/:7&Sc!ema*1
/element name"*Tra3ePrice;e9#est*1
/complexType1
/all1
/element name"*tickerSym<ol* type"*string*/1
//all1
//complexType1
//element1
/element name"*Tra3ePrice*1
/complexType1
/all1
/element name"*price* type"*$loat*/1
//all1
//complexType1
//element1
//sc!ema1
//types1
/message name"*5et&astTra3ePriceInp#t*1
/part name"*<o3y* element"*xs31:Tra3ePrice;e9#est*/1
//message1
/message name"*5et&astTra3ePriceO#tp#t*1
/part name"*<o3y* element"*xs31:Tra3ePrice*/1
//message1
/portType name"*Stock8#otePortType*1
/operation name"*5et&astTra3ePrice*1
/inp#t message"*tns:5et&astTra3ePriceInp#t*/1
/o#tp#t message"*tns:5et&astTra3ePriceO#tp#t*/1
//operation1
//portType1
/<in3ing name"*Stock8#oteSoap4in3ing* type"*tns:Stock8#otePortType*1
/soap:<in3ing style"*3oc#ment*
transport"*!ttp://sc!emas.xmlsoap.org/soap/!ttp*/1
/operation name"*5et&astTra3ePrice*1
/soap:operation soap)ction"*!ttp://example.com/5et&astTra3ePrice*/1
/inp#t1
/soap:<o3y #se"*literal*/1
//inp#t1
/o#tp#t1
/soap:<o3y #se"*literal*/1
//o#tp#t1
//operation1
//<in3ing1
/ser.ice name"*Stock8#oteSer.ice*1
/3oc#mentation17y $irst ser.ice//3oc#mentation1
/port name"*Stock8#otePort* <in3ing"*tns:Stock8#ote4in3ing*1
/soap:a33ress location"*!ttp://example.com/stock9#ote*/1
//port1
//ser.ice1
//3e$initions1
/0xml .ersion"*1.,* enco3ing"*=T>-%*01
/3escription xmlns"*!ttp://www.w+.org/ns/ws3l*
xmlns:tns"*!ttp://www.tmsws.com/ws3l',sample*
xmlns:w!ttp"*!ttp://sc!emas.xmlsoap.org/ws3l/!ttp/*
xmlns:wsoap"*!ttp://sc!emas.xmlsoap.org/ws3l/soap/*
target6amespace"*!ttp://www.tmsws.com/ws3l',sample*1

/?-- )<stract type --1
/types1
/xs:sc!ema xmlns:xs"*!ttp://www.w+.org/',,1/:7&Sc!ema*
xmlns"*!ttp://www.tmsws.com/ws3l',sample*
target6amespace"*!ttp://www.example.com/ws3l',sample*1

/xs:element name"*re9#est*1
/xs:complexType1
/xs:se9#ence1
/xs:element name"*!ea3er* maxOcc#rs"*#n<o#n3e3*1
/xs:complexType1
/xs:simpleContent1
/xs:extension <ase"*xs:string*1
/xs:attri<#te name"*name* type"*xs:string*
#se"*re9#ire3*/1
//xs:extension1
//xs:simpleContent1
//xs:complexType1
//xs:element1
/xs:element name"*<o3y* type"*xs:anyType* minOcc#rs"*,*/1
//xs:se9#ence1
/xs:attri<#te name"*met!o3* type"*xs:string* #se"*re9#ire3*/1
/xs:attri<#te name"*#ri* type"*xs:any=;I* #se"*re9#ire3*/1
//xs:complexType1
//xs:element1

/xs:element name"*response*1
/xs:complexType1
/xs:se9#ence1
/xs:element name"*!ea3er* maxOcc#rs"*#n<o#n3e3*1
/xs:complexType1
/xs:simpleContent1
/xs:extension <ase"*xs:string*1
/xs:attri<#te name"*name* #se"*re9#ire3*/1
//xs:extension1
//xs:simpleContent1
//xs:complexType1
//xs:element1
/xs:element name"*<o3y* type"*xs:anyType* minOcc#rs"*,*/1
//xs:se9#ence1
/xs:attri<#te name"*stat#s-co3e* type"*xs:anySimpleType*
#se"*re9#ire3*/1
/xs:attri<#te name"*response-p!rase* #se"*re9#ire3*/1
//xs:complexType1
//xs:element1
//xs:sc!ema1
//types1

/?-- )<stract inter$aces --1
/inter$ace name"*;2ST$#lInter$ace*1
/$a#lt name"*Client2rror* element"*tns:response*/1
/$a#lt name"*Ser.er2rror* element"*tns:response*/1
/$a#lt name"*;e3irection* element"*tns:response*/1
/operation name"*5et* pattern"*!ttp://www.w+.org/ns/ws3l/in-o#t*1
/inp#t message&a<el"*In* element"*tns:re9#est*/1
/o#tp#t message&a<el"*O#t* element"*tns:response*/1
//operation1
/operation name"*Post* pattern"*!ttp://www.w+.org/ns/ws3l/in-o#t*1
/inp#t message&a<el"*In* element"*tns:re9#est*/1
/o#tp#t message&a<el"*O#t* element"*tns:response*/1
//operation1
/operation name"*P#t* pattern"*!ttp://www.w+.org/ns/ws3l/in-o#t*1
/inp#t message&a<el"*In* element"*tns:re9#est*/1
/o#tp#t message&a<el"*O#t* element"*tns:response*/1
//operation1
/operation name"*@elete* pattern"*!ttp://www.w+.org/ns/ws3l/in-o#t*1
/inp#t message&a<el"*In* element"*tns:re9#est*/1
/o#tp#t message&a<el"*O#t* element"*tns:response*/1
//operation1
//inter$ace1

/?-- Concrete 4in3ing O.er HTTP --1
/<in3ing name"*;2ST$#lInter$aceHttp4in3ing*
inter$ace"*tns:;2ST$#lInter$ace*
type"*!ttp://www.w+.org/ns/ws3l/!ttp*1
/operation re$"*tns:5et* w!ttp:met!o3"*52T*/1
/operation re$"*tns:Post* w!ttp:met!o3"*POST*
w!ttp:inp#tSerialiAation"*application/x-www-$orm-
#rlenco3e3*/1
/operation re$"*tns:P#t* w!ttp:met!o3"*P=T*
w!ttp:inp#tSerialiAation"*application/x-www-$orm-
#rlenco3e3*/1
/operation re$"*tns:@elete* w!ttp:met!o3"*@2&2T2*/1
//<in3ing1

/?-- Concrete 4in3ing wit! SO)P--1
/<in3ing name"*;2ST$#lInter$aceSoap4in3ing*
inter$ace"*tns:;2ST$#lInter$ace*
type"*!ttp://www.w+.org/ns/ws3l/soap*
wsoap:protocol"*!ttp://www.w+.org/',,+/,-/soap/<in3ings/HTTP/*
wsoap:mep@e$a#lt"*!ttp://www.w+.org/',,+/,-/soap/mep/re9#est-
response*1
/operation re$"*tns:5et* /1
/operation re$"*tns:Post* /1
/operation re$"*tns:P#t* /1
/operation re$"*tns:@elete* /1
//<in3ing1


/?-- Be< Ser.ice o$$ering en3points $or <ot! <in3ings--1
/ser.ice name"*;2ST$#lSer.ice* inter$ace"*tns:;2ST$#lInter$ace*1
/en3point name"*;2ST$#lSer.iceHttp2n3point*
<in3ing"*tns:;2ST$#lInter$aceHttp4in3ing*
a33ress"*!ttp://www.example.com/rest/*/1
/en3point name"*;2ST$#lSer.iceSoap2n3point*
<in3ing"*tns:;2ST$#lInter$aceSoap4in3ing*
a33ress"*!ttp://www.example.com/soap/*/1
//ser.ice1
//3escription1
/3e$initions name"*HelloSer.ice*
target6amespace"*!ttp://www.examples.com/ws3l/HelloSer.ice.ws3l*
xmlns"*!ttp://sc!emas.xmlsoap.org/ws3l/*
xmlns:soap"*!ttp://sc!emas.xmlsoap.org/ws3l/soap/*
xmlns:tns"*!ttp://www.examples.com/ws3l/HelloSer.ice.ws3l*
xmlns:xs3"*!ttp://www.w+.org/',,1/:7&Sc!ema*1

/message name"*SayHello;e9#est*1
/part name"*$irst6ame* type"*xs3:string*/1
//message1
/message name"*SayHello;esponse*1
/part name"*greeting* type"*xs3:string*/1
//message1
/portType name"*HelloCPortType*1
/operation name"*sayHello*1
/inp#t message"*tns:SayHello;e9#est*/1
/o#tp#t message"*tns:SayHello;esponse*/1
//operation1
//portType1
/<in3ing name"*HelloC4in3ing* type"*tns:HelloCPortType*1
/soap:<in3ing style"*rpc*
transport"*!ttp://sc!emas.xmlsoap.org/soap/!ttp*/1
/operation name"*sayHello*1
/soap:operation soap)ction"*sayHello*/1
/inp#t1
/soap:<o3y
enco3ingStyle"*!ttp://sc!emas.xmlsoap.org/soap/enco3ing/*
namespace"*#rn:examples:!elloser.ice*
#se"*enco3e3*/1
//inp#t1
/o#tp#t1
/soap:<o3y
enco3ingStyle"*!ttp://sc!emas.xmlsoap.org/soap/enco3ing/*
namespace"*#rn:examples:!elloser.ice*
#se"*enco3e3*/1
//o#tp#t1
//operation1
//<in3ing1
/ser.ice name"*HelloCSer.ice*1
/3oc#mentation1BS@& >ile $or HelloSer.ice//3oc#mentation1
/port <in3ing"*tns:HelloC4in3ing* name"*HelloCPort*1
/soap:a33ress
location"*!ttp://www.examples.com/SayHello/*1
//port1
//ser.ice1
//3e$initions1

JAX-RPC/JAX-WS/JAXB
W"a! is JAX-RPC?
JAX-RPC s!ands or Java API or X'L-based RPC$ I!4s an API or b&i#din( Web
services and c#ien!s !"a! &sed re%o!e ,roced&re ca##s /RPC0 and X'L$ O!en
&sed in a dis!rib&!ed c#ien!>server %ode#+ an RPC %ec"anis% enab#es c#ien!s
!o e.ec&!e ,roced&res on o!"er s)s!e%s$
In JAX-RPC+ a re%o!e ,roced&re ca## is re,resen!ed b) an X'L-based ,ro!oco#
s&c" as SOAP$ 3"e SOAP s,ecifca!ion defnes enve#o,e s!r&c!&re+ encodin(
r&#es+ and a conven!ion or re,resen!in( re%o!e ,roced&re ca##s and
res,onses$ 3"ese ca##s and res,onses are !rans%i!!ed as SOAP %essa(es
over 233P$ In !"is re#ease+ JAX-RPC re#ies on SOAP ;$; and 233P ;$;$
Java API for XML-based RPC #,A$-)(*% allows a ,ava application to invoke a ,ava-based
Web Service with a known description while still being consistent with its WS." description. It
can be seen as ,ava )!Is over Web services. ,A$-)(* /.0 was renamed ,A$-WS /.0 #,ava A(I
for $!" Web Services%. ,A$-)(* 1 is deprecated with ,ava 2.
314
'he ,A$-)(* service
utili5es W6* #World Wide Web *onsortium% standards like WS." or Web Service .escription
"anguage
3/4
It works as follows7
1. A ,ava program invokes a method on a stub #local ob8ect representing the remote service%
/. 'he stub invokes routines in the ,A$-)(* )untime System #)S%
6. 'he )S converts the remote method invocation into a S9A( message
:. 'he )S transmits the message as an &''( re+uest
'he advantage of such a method is that it allows the Web Service to be implemented at server-
side as a Servlet or ,; container. 'hus, Servlet or ,; applications are made available through
Web services.
W"a! is JAX-WS?
JAX-WS ?$< is !"e s&ccessor o JAX-RPC ;$; - !"e Java API or X'L-based Web
services$ I ,ossib#e+ JAX-WS s"o&#d be &sed ins!ead as i! is based on !"e %os!
recen! ind&s!r) s!andards$
6 JAX-WS s!i## s&,,or!s SOAP ;$; over 233P ;$;+ so in!ero,erabi#i!) wi## no! be
a*ec!ed$ 3"e sa%e %essa(es can s!i## Kow across !"e wire$
6 JAX-WS s!i## s&,,or!s WSDL ;$;+ so w"a! )o&4ve #earned abo&! !"a!
s,ecifca!ion is s!i## &se&#$ A WSDL ?$< s,ecifca!ion is nearin( co%,#e!ion+
b&! i! was s!i## in !"e works a! !"e !i%e !"a! JAX-WS ?$< was fna#iGed$
W"a! is !"e di*erence be!ween JAX--WS and JAX-RPC?
Java API or X'L-Based RPC /JAX-RPC0 is a Le(ac) Web Services Java API+ i!
&ses SOAP and 233P !o do RPCs over !"e ne!work and enab#es b&i#din( o
Web services and Web a,,#ica!ions based on !"e SOAP ;$; s,ecifca!ion+ Java
S- ;$F or #ower$JAX-WS ?$< is !"e s&ccessor !o JAX-RPC ;$;$ JAX-WS s!i##
s&,,or!s SOAP ;$; over 233P ;$;+ so in!ero,erabi#i!) wi## no! be a*ec!ed$
2owever !"ere are #o!s o di*erences5
JAX-WS %a,s !o Java L$< and re#ies on %an) o !"e ea!&res new in Java L$<
#ike Web Service anno!a!ions$
JAX-RPC "as i!s own da!a %a,,in( %ode#+ JAX-WS4s da!a %a,,in( %ode# is
JAXB$ JAXB ,ro%ises %a,,in(s or a## X'L sc"e%as$
JAX-WS in!rod&ces %essa(e-orien!ed &nc!iona#i!)+ d)na%ic as)nc"rono&s
&nc!iona#i!) w"ic" are %issin( in JAX-RPC$
JAX-WS a#so add s&,,or!+ via JAXB+ or '3O'+ !"e new a!!ac"%en!
s,ecifca!ion$
W"a! is JAXB?
X'L and Java !ec"no#o() are reco(niGed as idea# b&i#din( b#ocks or
deve#o,in( Web services and a,,#ica!ions !"a! access Web services$ A new
Java API ca##ed Java Arc"i!ec!&re or X'L Bindin( /JAXB0 can %ake i! easier !o
access X'L doc&%en!s ro% a,,#ica!ions wri!!en in !"e Java ,ro(ra%%in(
#an(&a(e$
W"a! are !"e s!e,s !o Use JAXB?
The general steps to use the JAXB API are:
1. Bind the schema:
It requires two steps:
o enerate classes
o !ompile classes

". #nmarshal
It includes the $ollowing steps:
o enerate content tree
o %alidate &optional'
o Process the content

(. )arshal
JAXP is Ja*a API $or X)+ Processing, which pro*ides a plat$orm $or us to Parse the X)+ -iles
with the ./) /r 0AX Parsers.
1here as JAXB is Ja*a Architecture $or X)+ Binding, it will make it easier to access X)+
documents $rom applications written in the Ja*a programming language.
-or 23ample : !omputer.3ml -ile, i$ we can want to access the data with JAXP, we will 4e
per$orming the $ollowing steps 1' !reate a 0AX Parser or ./) Parser and then PArse the data,
i$ we use ./), it may 4e memory intensi*e i$ the document is too 4ig. 0uppose i$ we use 0AX
parser, we need to identi$y the 4eginning o$ the document. 1hen it encounters something
signi$icant &in 0AX terms, an 5e*ent5' such as the start o$ an X)+ tag, or the te3t inside o$ a tag,
it makes that data a*aila4le to the calling application.
Then !reate a content handler that de$ines the methods to 4e noti$ied 4y the parser when it
encounters an e*ent. These methods, known as call4ack methods, take the appropriate action
on the data they recei*e.
The Same Operations if it is performed by JAXB, the following steps needs to be
performed to access the Computer.ml
1. Bind the schema $or the X)+ document.
". #nmarshal the document into Ja*a content o46ects. The Ja*a content o46ects represent
the content and organi7ation o$ the X)+ document, and are directly a*aila4le to your
program. A$ter unmarshalling, your program can access and display the data in the X)+
document simply 4y accessing the data in the Ja*a content o46ects and then displaying it.
There is no need to create and use a parser and no need to write a content handler with
call4ack methods. 1hat this means is that de*elopers can access and process X)+ data
without ha*ing to know X)+ or X)+ processing

Вам также может понравиться