The document discusses SOAP, describing it as a protocol specification for exchanging structured information in web services using XML format. It outlines the key parts of a SOAP message including the envelope, header, body and optional fault. The document then provides an example SOAP request and discusses how WSDL and XSD describe the structure and data types of a web service. It evaluates different options for working with SOAP in Scala including rolling your own implementation, using JAXB, Apache CXF, and ScalaXB which generates case classes. Finally, it notes some common pitfalls like Sax parsing errors and timeouts when interacting with web services.
3. Simple Object Access Protocol
A protocol specification for exchanging sturctured information in the
implementation of WebServices that uses XML format and usually
uses HTTP or SMTP for message negotiation.
Allows for namespacing
Flexibility
4. Parts of SOAP
Envelope - Required
Identifies the XML document as a SOAP message.
Header - Optional
Passes along application level info that is processed by SOAP
nodes along the way
Body - Required
The information on the message that you are trying to send
Fault - Optional
Error and Status information
6. WSDL & XSD
WSDL
Describes the service and operations available for that service.
Its about the functionality of the service
XSD
Describes the structure of the complex datatypes of the service
Its about the sturcture of the objects (types, fields, restrictions like
max leghth)
They work together to give you a contract for the service
8. Roll Your Own
Pros:
You control all the details.
Cons:
You control all the details.
You are forced to think about lower level details.
9. JAXB
Java Architecture for XML Binding
https://netbeans.org/kb/docs/websvc/jaxb.html
Java standard for binding XML schemas to Java classes. Allows
converting Java objects to XML documents, and vice versa, based
on JAXB annotations on the corresponding Java classes.
Pros:
It handles all the crufty work for you.
Well tested
Cons:
Doesnt generate the code from the wsdl for you.
Annotations clutter up your code.
10. Apache CXF
http://cxf.apache.org
CXF helps you build and develop services using frontend
programming APIs, like JAX-WS and JAX-RS. These services can
speak a variety of protocols such as SOAP, XML/HTTP, RESTful
HTTP, or CORBA and work over a variety of transports such as
HTTP, JMS or JBI.
Pros:
Its an apache project!
Wraps JAXB
Hides away the annotations for you in generated code.
Cons:
Generates java
11. ScalaXB
http://scalaxb.org
Eugene Yokota - @eed3si9n
Pros:
For the most part handles receiving faults pretty well
Generates Scala that uses the cake pattern for implementation
details
You end up with case classes to use for the messages created
Cons:
Not as active as some other open source projects.
15. File structure
Place your wsdl/xsd
files
poetpuisst
rjc/lgn.b
bidst
ul.b
scmi/s
r/anxd
scmi/sl
r/anwd
scmi/cl
r/ansaa
16. Using the calls
tatProiLouSrie1{
ri eidcokpevcV
vlsrie=(e Proitbeop2idns
a evc
nw eidcalSa1Bnig
wt saabSaCins
ih clx.oplet
wt saabDsacHtCins{)srie
ih clx.ipthtplet }.evc
}
17. Generated Methods
/ fo tre/r_aae
/ rm agtscmngd
/ Gnrtdb < he=ht:/clx.r/>clx<a.
/ eeae y a rf"tp/saabog"saab/>
pcaei.rn.eidc
akg otetproi
tatProitbeop{
ri eidcalSa
dfgttm(:
e eAos)
Ete[clx.al[n] i.rn.eidcGttmRsos]
ihrsaabFutAy, otetproi.eAosepne
dfgttmcegteeetae Oto[tig)
e eAoiWih(lmnNm: pinSrn]:
Ete[clx.al[n] i.rn.eidcGttmcegtep
ihrsaabFutAy, otetproi.eAoiWihRso
ne
s]
dfgttmcubreeetae Oto[tig)
e eAoiNme(lmnNm: pinSrn]:
Ete[clx.al[n] i.rn.eidcGttmcubrep
ihrsaabFutAy, otetproi.eAoiNmeRso
ne
s]
dfgtlmnSmo(lmnNm:Oto[tig)
e eEeetybleeetae pinSrn]:
Ete[clx.al[n] i.rn.eidcGtlmnSmoRs
ihrsaabFutAy, otetproi.eEeetyblep
os]
ne
}
18. Clean it up a bit
tatProiLouSrie2{
ri eidcokpevcV
piaeti]vlsrie=(e Proitbeop2idns
rvt[hs a evc
nw eidcalSa1Bnig
wt saabSaCins
ih clx.oplet
wt saabDsacHtCins{)s
ih clx.ipthtplet }.
evc
rie
dfgttm( ={
e eAos)
vlfutrtm =sriegttm(
a alOAos
evc.eAos)
futrtm.ih.a(alTProiTbeal)
alOAosrgtmpfutoeidcalFut
.etmpaoRsosTEeet
lf.a(tmepneolmn)
}
piaeti]dffutoeidcalFutfut FutAy)=
rvt[hs e alTProiTbeal(al: al[n]
<apn t ormdl>
mpig o u oes
piaeti]dfaoRsosTEeetaos GttmRsos)=
rvt[hs e tmepneolmn(tm: eAosepne
<apn t ormdl>
mpig o u oes
}
19. Security Header
tatOroplet etnsSaCins1{htCin:HtCins=
ri uSaCins xed oplet1
tplet tplet
>
oerd lz vlsaCin =nwWsoplet{
vrie ay a oplet
e sSaCin }
tatOropletetnsSa1Cin {
ri uSaCin xed op1let
oerd dfrqetepnebd:NdSq
vrie e eusRsos(oy oee,
haes NdSq
edr: oee,
soe Nmsaeidn,
cp: aepcBnig
ades UI
drs: R,
wbehd Srn,
eMto: tig
ato:Oto[R]:
cin pinUI)
Ete[op1al[eal,(oee
ihrSa1FutDti] NdS
q NdSq]={
, oee)
sprrqetepnexlihoseNmsae
ue.eusRsos(mWtHitdaepc,
haes+ scrtHae,..)
edr + euiyedr .
}
}
lz vlscrtHae =<xlfrhae"
ay a euiyedr
"m o edr>
}
20. Security Header (cont.)
tatProiLouSrie3{
ri eidcokpevcV
piaeti]vlsrie=(e Proitbeop2idns
rvt[hs a evc
nw eidcalSa1Bnig
wt OSaCins
ih uoplet
wt saabDsacHtCins{)s
ih clx.ipthtplet }.
evc
rie
dfgttm( ={
e eAos)
/ terqetwl cnanorhae nw
/ h eus il oti u edr o
vlfutrtm =sriegttm(
a alOAos
evc.eAos)
futrtm.ih.a(alTProiTbeal)
alOAosrgtmpfutoeidcalFut
.etmpaoRsosTEeet
lf.a(tmepneolmn)
}
piaeti]dffutoeidcalFutfut FutAy)=
rvt[hs e alTProiTbeal(al: al[n]
<apn t ormdl>
mpig o u oes
piaeti]dfaoRsosTEeetaos GttmRsos)=
rvt[hs e tmepneolmn(tm: eAosepne
<apn t ormdl>
mpig o u oes
}
21. Pitfalls We Have Encountered
Sax Parsing Errors
Happens when the service you are connected to does not adhere
to the wsdl that you are using
Timeouts
We ended up writing a nice little wrapper around API requests to
catch the timeoutErrors and handle them appropriately