Sunteți pe pagina 1din 4

JAXRS classes: Client objects: HttpURLConnecton HttpClient Client Using java.net packages to invoke.

Jersery Client

Client Request Handlers Object WebResource AsyncWebResource Client side post Listeners: ItypeListener< ! - Jersey Client JAXRS Annotations: "#U $"%& $"#'( $")&L& & "#at"#rovi+er "/uery#ara.$"#at-#ara. "1or.#ara.$ "Hea+er#ara. "Cookie#ara.$")e0ault3alue "Consu.es$"#ro+uces * Can be a++e+ on ,et-o+s an+ classes Can be a++e+ on ,et-o+s an+ (ervices o +esignate class as Co.ponent o rea+ t-e para.eters 0ro. classi0ie+ at +i00erent levels in inco.ing re2uest. Jersey Client Jersey Client

- o +e0ine content accepte+ an+ returne+ by service. Can be place+ on .et-o+ an+ class "Conte4t - Injects in0or.ation in to class bean or i.ple.entation class "#rovi+er - Use+ 0or anyt-ing t-at is intereste+ to server runti.e suc- as ,essage5o+yRea+er ,essage5o+yWriter HttpHea+ers - getRe2uestHea+er$ getRe2uestCookies 6 only 7 .et-o+s8 UriIn0o - get/uery#ara.eters$ get#at-#ara.eters 6 only 7 .et-o+s8 ,essage5o+yRea+er - ,aps an H #Re2uest entity bo+y to .et-o+ para.eters ,essage5o+yWriter - 'n t-e response si+e$ return value is .appe+ to entity bo+y by using t-is. Response - I0 to .ap H # -ea+ers9Cookie9status Response.Response5uil+er - o .ake t-e response object using 1aca+e pattern (tatus ype - All custo. e4ception :it- +i00erent +escription in status co+es can be i.ple.ente+

(tatus "Re2uest(cope+ "Application(cope+

- Class -ol+ing all associate+ H # co+es. - JA;R( converting a C)I 5ean. -e beans .ust be pro4y-able

Runti.e content negotation is +one by calling t-e .et-o+s on Respose5uil+er 0or setting t-e .e+ia types$ languages an+ enco+ings Note: <8 W-en a H # ,et-o+ is annotate+ :it- "#at- even a0ter class t-en it is calle+ as sub resource. 78 A class :-ic- is annotate+ at .et-o+ level it is calle+ sub-resource i0 not annotate+ on top o0 class Form parameters Encodin in Ser!ice: application/x-www-form-urlencoded H""# codes: <44 * In0or.ation 744 * Application status =44 * Content (tatus >44 * Application errors ?44 * Internal (erver errors >@= * I0 ,et-o+ type is not supporte+ by t-e service. >@> * Resource not 0oun+ 7@@ * (uccess an+ server success0ully processe+ user re2uest "#at- 6Aapplication94.l$ application9json$2B@.?8 * Here t-e ,I,& type is picke+ up on t-e value o0 priority bet:een @.< to <. < being -ig-est. - ,ost speci0ic ele.ent is picke+ :-ic- is application94.l over :il+car+. Note: Cee+s to be care0ul :-en resolving t-e URLDs... i.proper URL .atc-ing coul+ lea+ to con0usion. $eneric E%ceptions WebApplication&4ception H JAX RS Ser!ice Re istration: Application - Class :-ic- e4ten+s an+ i.ple.ents .et-o+ an+ a++ all (ervice$ #rovi+er classes. - All e4ceptions nee+s to be t-ro:n using # co+es

JAX&S Handlers Annotations: "('A#,essageHan+ler

"Han+lerC-ain "('A#,essageHan+lers init#ara.s attribute o0 ('A#,essageHan+ler use+ to speci0y t-e para.eters o0 t-e -an+ler to be initialiEe+. 'essa e Handlers: ('A#,essageHan+ler o -an+le any c-anges on to t-e ('A#&nvelope object :-en sen+ing a :eb service re2uest. Can also :ork :it- Hea+ers9Attac-.ents 9)igital (ignatures Logical,essageHan+ler o -an+le any c-anges on to t-e ('A# 5o+y ele.ent :-en sen+ing a :eb service re2uest ('A#,essageConte4t Logical,essageConte4t Actual conte4t object at t-e -an+ler level. Actual conte4t object at t-e .essage level.

,essageConte4t.,&((A%&F'U 5'UC)F#R'#&R G * o 0in+ :-et-er inco.ing9outgoing .essage :-en invoking :eb service. Returns boolean. Note: <8 Logical Han+lers are calle+ 0irst 0ollo:e+ by ('A# ,essage Han+ler :-en on client si+e an+ itDs t-e reverse :-en on server si+e. 78 ('A# Han+lers at server si+e can be con0igure+ using -an+ler-c-ain.4.l on top o0 t-e class using "Han+lerC-ain annotation. =8 At client si+e$ a++ -an+ler-c-ain on java4.4.l.:s.5in+ing a0ter casting t-e port object to java4.4.l.:s.5in+ing#rovi+er an+ t-en calling getHan+lerC-ain68 .et-o+ :-ic- return access to list. >8 Han+lers can be create+ using -an+ler con0iguration 0ile a++e+ to t-e 0ile as para.eter 0or "Han+lerC-ain annotation an+ Dna.eD para.eter is +eprecate+. JAX&S: Client Classes: )ispatc(ervice 5in+ing#rovi+er &n+#oint AsyncHan+er6I8 Ser!er side Handlers: Han+lerResolver6I8 - Cee+s to i.ple.ent base+ on #ortIn0o para. to associate t-e -an+ler-c-ain

JAX&S SOA# (eans: &le.ent

JAX&S Annotations: "Web(ervice "Web(erviceConte4t "Web(ervice#rovi+er "Web(erviceRe06:s+lLocation8 * Re0er any Web (ervice as para. class "Resource6 to inject to a class8 "Web,et-o+ ",et-o+#ara. "WebResult "('A#5in+ing "#ostConstruct * Callback -an+ler "#re)estroy * Callback -an+ler Note: <8 Classes s-oul+ not be +eclare+ static$abstract or 0inal. 78 I.ple.enting class .ust -ave a +e0ault public constructor. =8 I.ple.enting class s-oul+nDt -ave 0inaliEe68 .et-o+. 78 .et-o+s nee+s to be public an+ s-oul+ not be +eclare+ static or 0inal. SOA# Faults: ,o+ele+ 1aults - ,aps to e4ception e4plicitly t-ro:n 0ro. Java Un-.o+ele+ 1aults - ,aps to e4ception t-at is generate+ runti.e Cot 0ro. business logic ,o+ele+ 1aults - Custo. &4ception classes 0ro. 5usiness Logic Un.o+ele+ 1ault * Runti.e&4ception t-ro:n 0ro. a server run ti.e JAX&S Client: &n+#oint JAX)R#C Ser!ice Class: Re.ote6I8 JAX)R#C Handlers: Han+ler %enericHan+ler Han+lerC-ain Han+lerRegistry Han+lerIn0o JAX)R#C Client Handler: %enericHan+ler6C8

S-ar putea să vă placă și