Scalaxb preso

1,124 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,124
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Scalaxb preso

  1. 1. So We Have To Use SOAP!? Trent Johnson @trentio trent.johnson@banno.com
  2. 2. What is SOAP?
  3. 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. 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
  5. 5. Example SOAP Request <xlvrin"."> ?m eso=10? <opEvlp xlssa=ht:/w.3og20/5sa-neoe> sa:neoe mn:op"tp/www.r/030/opevlp" <opHae> sa:edr <:Scrt>. <oScrt> o euiy.. /:euiy <sa:edr /opHae> <opBd> sa:oy <:eSokrc xlsm"tp/wweapeogsok> mGttcPie mn:=ht:/w.xml.r/tc" <:tcNm>B<mSokae mSokaeIM/:tcNm> <mGttcPie /:eSokrc> <sa:oy /opBd> <sa:neoe /opEvlp>
  6. 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
  7. 7. What Can We Use
  8. 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. 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. 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. 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.
  12. 12. ScalaXB and How it Works
  13. 13. Setting Up A Simple Project Has options for mvn, ivy, cli, and sbt
  14. 14. Plugin plugins.sbt adbPui(ogsaab %"b-clx"%".." dStlgn"r.clx" stsaab 112) build.sbt saabetns clxStig sucGnrtr i Cmie<=saabi Cmie oreeeaos n opl + clx n opl pcaeaei saabi Cmie: "otetproi.op akgNm n clx n opl = i.rn.eidcsa" dsacVrini saabi Cmie: ".01 iptheso n clx n opl = 01." lbayeednis<=(iptheso i saabi Cmie{d = irrDpnece + dsacVrin n clx n opl) v > "e.aaidrdsac"% "ipthcr"%d ntdtbne.ipth % dsac-oe v }
  15. 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. 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. 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. 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. 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. 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. 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
  22. 22. We're Hiring Talk to one of the guys here from banno banno.com/jobs

×