D.
KaeliandK.
Sachs(Eds.
):SPECBenchmarkWorkshop2009,LNCS5419,pp.
439–450,2009.
Springer-VerlagBerlinHeidelberg2009DesigningWeb-BasedMobileServiceswithRESTClaudioRivaandMarkkuLaitkorpiNokiaResearchCenter,P.
O.
Box408,FIN-00045NOKIAGROUP,Finland{claudio.
riva,markku.
laitkorpi}@nokia.
comAbstract.
TheWebisemergingasthefavoriteplatformfordeliveringapplica-tionsandservices.
TheRESTarchitecturalstylecomprisesthekeyprinciplesbehinditsdesignandsuccess.
WhileRESTisoriginallydefinedinthecontextofpublishinghypermediadocuments,itisbecomingapopularmethodforim-plementingWebservicesaswell.
Thegoalofthispaperistoexploretheprin-ciplesoftheRESTstyleforbuildingmobileservicesandtoaddressthemobilespecificconstraints.
Wepresentthedesignmethodthatwehavefollowedforbuildingabasicphotostorageservice.
OurpreliminaryevaluationconfirmsthatRESTisaflexibleandextensibleapproachforbuildingmobileservices.
Keywords:Softwarearchitectures,mobileservices,serviceorientedarchitec-tures,weborientedarchitectures,REST.
1IntroductionNewcompellingmobileservicesareexpandingthecapabilitiesofmobiledevicesbesidesthetraditionalservicesofvoiceandshortmessaging.
Nowadaysmodernmo-biledeviceshavebuilt-insupportforseveralmobileserviceslikewebbrowsing,mo-bileemail,mobilesearch,photosharing,newsreaders,internetradioandnavigation.
ThepromiseofthemobileInternetisturningintorealityformanyconsumers.
Insomecases,themobileservicesaretightlybundledwiththedevicesinordertomaximizetheiruserexperience,e.
g.
BlackberryResearchinMotion's(RIM)pushemailservice,NokiaN-GageArenaandNokiaS60'ssupportformobilesearchandphotosharingwithFlickr.
WiththeavailabilityoffastandconvenientmobileInter-net,weexpectthatmobileserviceswillrepresentasignificantvalue-addingelementoffuturedevices.
TheWorldWideWebisemergingasthefavoriteplatformfordeliveringapplica-tionsandservices.
TheWeb2.
0phenomenonisexploitingthewebbrowserasacross-platformruntimeenvironmentforshippingandexecutingapplications.
Special-izedlibraries(e.
g.
Ajax)andframeworks(e.
g.
RubyonRails)havebeendevelopedforfacilitatingthecreationofinteractivewebapplications.
TheWebisalsobecomingthepreferredplatformfordeliveringservicestothirdparties.
InternetcompaniesopentheirfunctionalityandtheirdatatotheexternaldevelopersthroughpublicinterfacesimplementedwithWebservices.
Thesepublicinterfaces,typicallycalledOpenAPIsorWebAPIs,arekeyenablersoftheWeb2.
0phenomenon.
440C.
RivaandM.
LaitkorpiTherearetwodominantparadigmsforcreatingWebAPIs,namelySOAP/WS-*andREST.
SOAPisanXMLbasedprotocolforexchangingmessagesoveracom-puternetwork,typicallytunnelingoverHTTP,andisthefoundationforthemorecomplexWebServicesstack,alsoknownasWS-*[10,11].
SOAPprovidesdifferenttypesofmessagingpatterns,buttheremoteprocedurecalliscommonlyusedwhenbuildingOpenAPIs.
ASOAPbasedOpenAPItypicallyprovidesasetofremoteoperationsthatcanbeinvokedovertheWeb.
REST(RepresentationStateTransfer)followsadifferentphilosophythanSOAPbyfocusingondatainsteadofoperations.
RoyFielding,oneoftheprincipalauthorsoftheHypertextTransferProtocol(HTTP)[2],coinedthetermREST1inhisdoctoraldissertation[1].
RESTisanarchitecturalstylederivedfromtheWeb,anditsarchitec-turalelementsandconstraintsaimatcollectingthefundamentaldesignprinciplesthatenablethegreatscalability,growthandsuccessoftheWeb.
RESTisoriginallyde-finedinthecontextofpublishinghypermediadocumentsbutithasbecomeapopularmethodforpublishingWebservicesasaWeb-friendlyalternativetoSOAP.
RESTisprimarilyfocusedondefiningandaddressingwebresources(likedocumentsandimages)andformanagingtheirrepresentations.
AlthoughthereisonlyoneversionofRESTdefined,itdoesnotmeanthateverysystemissupposedtobeequallyRESTful.
Therefore,theconstraintsofRESTshouldbetakenasatoolkitthathelpsthearchitectidentifythebenefitsorcosts,dependingonwhethertheactualrequirementsfittheconstraints.
ThegoalofthepresentresearchistoinvestigatehowtoapplytheprinciplesoftheRESTfuldesigntothedevelopmentofmobileservices.
Inparticular,ourfocusistoanalyzethebenefitsandlimitationsofRESTinamobilecontextandtoelaborateaproperdesignprocess.
DesigningRESTservicesisaboutmodelingresourcesthatarepublishedontheWebandthefunctionalityisimplementedwithalimitedsetofop-erationsonthoseresources.
Thedesignprocessresemblesthedata-drivendesignprocesses(e.
g.
fordatabases).
Inthispaper,wepresentourpreliminaryworkofde-signingRESTservices.
First,wepresentthekeyrationaleandconstrainsofRESTdesigninamobileenvironment.
Then,wepresentourdesignprocessandweapplyittothecasestudyofdesigningaphotostorageservices.
Finally,weconcludewithapreliminaryevaluation.
2MobileServiceswithREST:RationaleandConstraintsMobileservicesallowuserstoaccessnetworkservicesthroughtheuserinterfaceofamobiledevice.
Theyconsistofaclientapplication,theclientcomponentthatpro-videstheuserinterfaceonthemobiledevice,andaservicebackend,theservercom-ponentinthenetworkthatprovidestheremotefunctionality.
Theimplementationoftheclientapplicationheavilydependsonthecapabilitiesofthemobiledeviceandtheavailablerun-timeenvironments.
Often,themobilesoft-waredevelopermustspecializetheclientapplicationstothevariousclientsinordertotakefulladvantageofthedevicespecificfeatures[5].
Theclientapplicationalso1TherearedifferentinterpretationsofREST.
Unlessotherwisespecifiedinthispaperwerefertoatrulyresource-orientedapproach,oftenreferredasRESTful.
DesigningWeb-BasedMobileServiceswithREST441needstoefficientlyinteractwiththebackendinordertofetchthedatathatispre-sentedintheuserinterface.
Thereareseveralmotivationstodesignthebackendac-cordingtotheRESTstyle:Itprovidesauniformmethodforaccessingtheresourcesindependentlyoftherun-timeenvironment(native,Java,Python,etc).
AnyclientthatsupportstheHTTPprotocoliscapableofaccessingtheRESTserviceswithouttheneedofanyadditionalmessagingframework.
Therepresentationofaresourcecanbenegotiatedatrun-timebetweentheclientandtheserver.
Thisenablesustosupportmobileoptimizedvariantsofthere-sourcesaccordingtotheneedsofthedevice.
TheRESTprinciplesfavorscalabilityandfastresponsetimes(e.
g.
throughcach-ing).
Thisisanimportantpointformobileservicesthatpotentiallyhaveahugeuserbaseofbillionsofusers.
Scalabilityisoftenahardtoreachqualityifnotproperlyaddressedearlyinthedesign.
However,themobileenvironmentposesadditionalchallengesandconstraintsoverthetypicalRESTdesign.
Wesummarizethembelow:Networklatency:mobiledatanetworks(2G,EDGE,3G)areoptimizedforcon-tentdownload.
Thebandwidthisoftensufficientformostofthescenarios(likevideostreaming),butthenetworklatencyisstillamajorissue.
Eveniffuturenetworksbeyond3G(e.
g.
HDSPA,WiMAX)willminimizethisproblem,areli-ablemobileserviceshouldmakefewassumptionsabouttheunderlyingdatanet-work.
Optimizingforhighlatencynetworkisakeyrequirementforsuccess.
Theroundtriptimeforsendingarequestandreceivingaresponsecanbeashighastwoseconds.
Toavoidperformancebottlenecks,thenumberofmessageex-changeswiththeservermustbekeptattheminimum.
ThisrequirementisoftenconflictingwithRESTservicesdevelopedforlowlatencynetworks.
Dataformats:verbosedataformats(e.
g.
XML)areslowtotransferandtoparse.
Mobiledevicesrequirelightweightformats.
Compactbinaryformatsareoftentheoptimalsolutionbuttheycompromisetheserviceinteroperability.
Often,thetradeoffisbetweenaproprietaryoptimizationandaninteroperablestandard.
Cachingpolicy:toreducethenetworktrafficthemobileservicesmustcachethedataonthedevicememory.
Cachingcanhappeneitherattheprotocollevel(e.
g.
theHTTPresponses)orattheapplicationlevel(e.
g.
theactualdata).
Offline/onlinebehavior:irregularnetworkconnectivityistypicalformobiledevices.
Mobileservicesmustdefineastrategyforsupportingofflineoperations.
Thinvs.
thickclients:howmuchlogicresidesontheclientandontheserver.
3DesigningRESTServicesThecoreentitiesoftheRESTdesignarethewebresources.
TodesigntheAPIswefollowadata-drivendesignprocessthatstartsbymodelingthedomainoftheAPIs.
Inthefollowingsectionswedescribeourbasicdesignprinciples,thedesignprocessandthestructureoftheRESTAPI.
442C.
RivaandM.
Laitkorpi3.
1DesignPrinciplesThebasicarchitecturalstyleisRESTwiththeHTTP.
ThefunctionalityisdefinedintermsofresourcesthataremanipulatedviaHTTPasanapplicationprotocol.
Aresourceisanentitythathas:nameandaddressidentifiedbyaURI[3]onestateatatimedefinedbyasetofattributesandtheirvaluesatleastonerepresentationthatencodethecurrentstateinaparticularcontenttypeTheallowedactionsontheresourcesarebasedontheHTTPprotocolwiththefol-lowingsemantics:GET:retrievesarepresentationofaresource.
Thisoperationissafewithnochangesthataclientcouldbeheldaccountablefor.
PUT:rewritesaresourcewithanewstatethatisenclosedintherequest.
Thisop-erationisidempotent(requestcanbere-processedwiththesamefinalstate).
POST:appendstheentityenclosedintherequesttotheresource.
Anewresourcemightbecreated.
Thisactionreturnseitherthelocationofthecreatedresourceortheresourcerepresentationafterappending.
Thisoperationisnotidempotent.
DELETE:removesthemappingbetweenaresourceanditsURI,thusmakingtheresourceinaccessible.
Thisoperationisidempotent.
EachrequestisauthenticatedindependentlyusingthestandardHTTPauthorizationheader.
Hence,thereisnoneedforsessioncontrolandcookies.
TheaccesscontrolforaresourceisconductedattheURIlevel.
Concerningthedataobjects,wesupporttheexchangeoftwotypesofstructureddata:containers(e.
g.
acollectionofphotos)andsingleitems(e.
g.
animage).
Besidesthestandardcontenttypesformedia(MIMEtypes[6]),wesupportcontenttypesforstructureddatafordifferentapplications:ATOM(application/atom+xml):widelypopularXMLbasedformatforblogsandmash-ups[7,8]JSON(application/json):lightweightformatforstructureddata[9]binaryJSON(application/x-bjson):ourownextensiontoJSONformattosupporttheexchangeofbinarydata.
WealsodefineadecorationmechanismforclientstocontroltheexactcontentofthemessagebodyoftheHTTPresponses.
IntheheaderoftheHTTPrequest,wecanaddacustomheadercalledx-decorationsthatcontainacommaseparatedlistofdecorationstobeappliedtotheresponse.
Wehavedefinedthefollowingdecorations:xlink-id:addbasicidentifierlinkstoobjectsxlink:addsallavailablelinkstoobjectsitem(id|summary|full):controlstheverbosityoftheitemswhenlistedinacontainerinline()=:outputsanoptimizedresponsethatincludestheassociateddatainonesinglerequest-responsecycle.
TheoutputDesigningWeb-BasedMobileServiceswithREST443formatdependsonthecontenttypeoftheresource.
ForJSONandXMLweusemultipart/related,forbinaryJSONandATOMweinlinethedatainplace.
Thecanbeanyoftheallowedcontenttypesofthelinkedre-source(e.
g.
image/jpg).
Thecanbeanyofthelinknamespub-lishedbytheresource(e.
g.
tn_tiny)3.
2DesignProcessDesigningRESTservicesinvolvemodelingwebresourcesandtheirURIs.
Therefore,wefollowadata-drivenapproachthatissummarizedinthreesteps:1.
Developingtheabstractdatamodel.
ThefirststepistoidentifytheconceptsandtheirassociationsthatarepartoftheAPI.
Forthistask,wefollowthetraditionaltechniquesofobject-orientedanalysisanddesign,focusingonalltherelevantnounsintheproblemdomain.
2.
Derivingthecoreresourcemodel.
Basedontheabstractdatamodel,weidentifytheprimaryresourcesoftheRESTdesign,i.
e.
thecentralconceptsoftheAPI.
Wedistinguishbetweentwotypesofresources:containers(collectionsofitems)anditems.
Besidestheprimaryresources,wecanalsoidentifythesecondaryresourcesthatcanbeaccessedfromtheprimaryresourcesthroughtheirassociations.
3.
DesigningtheURIspaceoftheAPI.
ThefinalstepistodefinetheURIspaceoftheAPI.
ForeachresourcewedefinetheURI,allowedmethods,contenttypes,andlinkstootherresources.
ThestructureoftheAPIisdescribedinthenextsection.
3.
3APIStructureThestructureoftheAPIisdocumentedusingfourelementsthataredescribedbelow:URIspace.
Eachresource(eitheracontaineroranitem)isaddressedbyoneURI.
Thenamecontainmentimpliesstrongsub-resourcerelationship.
Weusethefol-lowingsyntax:.
.
///where::encodestheowneroftheresource,suchasuser"john":encodestheprimaryresource,suchas"pho-tos"or"photo":encodestheassociationsfromtheprimaryresources,suchas"tagsofaphoto":querystringformultidimensionalprojections.
Methodsandcontenttypes:thisdescribestheavailableinteractionsonthere-sourcesandthesupportedcontenttypesLinks:traversableconnectionsfromoneresourcetoanother.
Itisacombinationofaname(semantics)andaURI(concreteaddress)Representations:actualdatacontentoftheresource444C.
RivaandM.
Laitkorpi4ExampleofRESTAPIforPhotosAsacasestudywehavedesignedthepotentialRESTAPIforaphotostorageservice.
Theserviceshouldprovidethefunctionalityforuploadingnewphotos,taggingthem,organizingthemintofoldersandassigningproperties.
Therearemanysimilarser-vicesontheWebthatprovideanAPIforstoringphotos:Flickr2andSmugmug3asexamples,buttheyareclearlyoperation-centricandonlyaccidentallyRESTful.
ThegoalofourcasestudyistodesignaphotostorageservicethatfollowstheRESTprin-ciplesandisusablefrommobiledevices.
Wedescribethedatamodel,thelistofwebresourceandseveralusecasestoaccesstheservice.
4.
1DataModelTheFigure1showsthesimpledatamodelforthephotostorageserviceandtheirattributes.
Wehaveincludedthefollowingconcepts:User:theauthenticateduserofthesystem.
EachuserhasauniqueloginnamePhoto:thedataobjectforaphoto.
Eachphotohasauniqueid.
Bag:auser-specificlabelforgroupingphotoobjectsinalbumsTag:apubliclydefinedlabelthatcanbeassociatedtoaphotoobjectContent:theactualbinaryrepresentationofthephoto(e.
g.
thejpgfile)Attr:anattributethatassignsavaluetoapropertyProp:apropertydefinitionwithsemantics,definedbyascopeandaname.
Tn:thebinaryrepresentationofathumbnailofaphoto.
Attr-prefix-nameBag-nameContentTag-nameTn-sizeUser-loginnamePhoto-idProp-prefix-name1*1***111*1****1Fig.
1.
AbstractdatamodelofthePhotoAPI4.
2CoreResourcesFromthedatamodelwecandirectlyderivethecoreresourcesoftheRESTAPI.
Belowwelistthecoreresources:PrimaryresourcesContainers:Photos,Tags,Bags,PropertiesItems:Photo,Tag,Bag,PropertySecondaryResourcesContainers:Thumbnailsofaphoto,Attributesofaphoto,Tagsofaphoto,BagsofaphotoItems:Content,Thumbnail,Attribute2http://www.
flickr.
com/services/api3http://www.
smugmug.
comDesigningWeb-BasedMobileServiceswithREST4454.
3APIStructureBasedonthecoreresourcemodel,wedefinethestructureoftheURIs.
Table1liststheURIsoftheresourcesandTable2documentsthesemanticoftheHTTPactions.
Table1.
StructureoftheAPIforPhotosURIOwnershipPrimaryprojectionAssociationDescriptionPhotos/users/{name}/photosPhotosforuser{name}(container)/users/{name}/photos/recentRecentphotosfor{name}(container)/users/{name}/photos/{photo-id}Photoitem/users/{name}/photos/{photo-id}/contentPhotocontentof{photo-id}/users/{name}/photos/{photo-id}/tns/tinyPhotothumbnail(50x50)/users/{name}/photos/{photo-id}/tns/smallPhotothumbnail(100x100)/users/{name}/photos/{photo-id}/tns/mediumPhotothumbnail(200x200)/users/{name}/photos/{photo-id}/tns/largePhotothumbnail(400x400)/users/{name}/photos/{photo-id}/tns/custom/{xsize};{ysize}Photothumbnailxsizexysize/users/{name}/photos/{photo-id}/attrsPhotoattributesfor{photo-id}(con-tainer)/users/{name}/photos/{photo-id}/attrs/{attr-prefix}/{attr-name}Photoattribute/users/{name}/photos/{photo-id}/tagsTagsfor{photo-id}(container)/users/{name}/photos/{photo-id}/tags/{tag-name}Phototag/users/{name}/photos/{photo-id}/bagsBagsfor{photo-id}(container)/users/{name}/photos/{photo-id}/bags/{bag-name}PhotobagTags/tagsAlltags(container)/tags/{tag-name}Tagitem/tags/{tag-name}/photosAllphotoswithtag{tag-name}(con-tainer)Bags/users/{name}/bagsAllbagsforuser{name}(container)/users/{name}/bags/{bag-name}Bagitem/users/{name}/bags/{bag-name}/photosAllphotosinbag{bag-name}(con-tainer)Properties/propsPublicproperties(container)/props/{prop-prefix}/{prop-name}Publicproperty446C.
RivaandM.
LaitkorpiTable2.
Supportedmethodsandcontent-typesfortheresources.
Unlessotherwisespecifiedallthemethodssupportthefollowingcontent-types:application/json,application/atom+xml,application/x-bjson.
ResourceMethodContent-typeDescriptionGETRetrievesthearrayofphotosPhotos(container)POSTimage/jpegAppendsanewphotoRecentphotos(container)GETRetrievesthearrayofrecentphotosGETRetrievesthephotoitemPUTReplacesthecontentoftheitemPhotoitemDELETERemovestheitemGETimage/jpegRetrievestheimagefilePhotocontentPUTimage/jpegReplacestheimagefilePhotothumbnailGETimage/jpegRetrievesthethumbnailfileGETRetrievesthearrayofattributesPhotoAttributes(container)POSTAddsanewattributetoaphotoGETRetrievesthevalueofanattributePhotoAttributePUTUpdatesthevalueofanattributeGETRetrievesthearrayoftagsTags(container)POSTAddanewtagtoatagcontainerGETRetrievesthetagdataPUTUpdatesthetagdataTagitemDELETERemovesthetagGETRetrievesthearrayofbagsBags(container)POSTAddsanewbagtoabagcontainerGETRetrievesthebagdataPUTReplacesthebagdataBagitemDELETERemovesthebag(butnotthecon-tent)GETRetrievesthearrayofpropertiesProperties(container)POSTCreatesanewpropertyGETRetrievesthedataaboutapropertyPUTUpdatesapropertyPropertyitemDELETERemovesaproperty4.
4UseCasesHowtoAccessthePhotoAPIUploadingaphotoTheusercanuploadaphotobysendingaPOSTrequesttoaPhotocontainer(e.
g.
/users/mary/photos)thebinarydatathatcontainsthejpgimageofthephoto.
Ifsuccessful,theservicesreplieswiththemessage"201Created"andtheLoca-tionheadercontainsthelinktothecreatedresource.
FetchingthelistofphotosTheusercanfetchthelistofphotosstoredinthesystemwithaGETrequestontherootPhotocontainer(e.
g.
/users/mary/photos).
TheresponseinJSONformatisanarraywiththeIDsofthephotos:DesigningWeb-BasedMobileServiceswithREST447{"photos":{"photo":[{"id":169},{"id":170},{"id":171},{"id":172},{"id":173},{"id":174},{"id":175},{"id":176}],"total":8,"start":0,"count":20}}Bypassingtheinlineheaderintherequesttheusercanrequestadditionalinforma-tiontobeaddedintheresponse.
Forinstance,wecaninlinethethumbnailsbyaddingtheheader:x-decorations:inline(image/jpeg)=tn_tiny.
TheresponseisamultipartmessagecontainingtheJSONdataandthethumbnails.
Fetchingthecontent/thumbnailofonephotoTheusercanfetchthecontentofonephotowithaGETrequestonthePhotoresource(e.
g.
/users/mary/photos/169/content).
Theresponseisthebinarydataofthejpegimage.
ThethumbnailcanberetrievedfromthesuitablethumbnailURI(e.
g.
/users/mary/photos/169/tns/small).
TaggingphotosBecauseasingletagissimplylikealabel,theusercanaddanewtagtoaphotobysendingaPUTrequesttoanon-existentTagresourceofthePhoto(e.
g.
/users/mary/photos/169/tags/Holiday).
Alternatively,theusercanuploadmultipletagsbyusingaPOSTrequestontheTagscontainerresourcewiththebodycontainingthetagnamesinJSONformat(e.
g.
{"tags":{"tag":[{"name":"Holiday"},{"name":"Maledives"}]}})TheusercanfetchthelistofallthephotoswithaparticulartagbysendingaGETrequesttotheTagresource(e.
g.
/tags/Holiday/photos).
Theresultisanarrayofphotos:{"photos":{"photo":[{"id":169},{"id":170}],"total":2,"start":0,"count":20}}Theusercanun-tagaphotosendingaDELETErequesttotheTagresourceofthePhoto(e.
g.
/users/mary/photos/169/tags/Holiday).
AttachingthegeolocationattributetoonephotoTheusercandefinenewpropertiesforthePhotoresourceandattachtheattributestoaparticularPhoto.
Inthiscaseweneedtodefineanewpropertyforstoringthegeolocationofaphoto(e.
g.
theproperty/loc/coord).
First,wesendaPOSTrequesttothePropertiescontainer(/props)withthenewpropertytocreate:{"prop":[{"name":"coord","prefix":"loc"}]}.
Then,wecanaddtheattrib-utetothephotobysendingaPUTrequesttothelocationofthephoto(e.
g.
/users/mary/photos/169/loc/coord)withthefollowingbody:{"attr":{"value":"45.
210.
7"}}.
5PreliminaryEvaluation5.
1PrototypeImplementationWehaveprototypedareferenceimplementationofthephotoservicethatwaspre-sentedintheprevioussection.
TheimplementationisbasedontheRubyonRails448C.
RivaandM.
Laitkorpiframework[4]thatprovidesseveralconvenientfeaturesfortheimplementationofRESTservices.
ToevaluatethebenefitsandthelimitationsoftheRESTdesignwehavetestedthebackedwiththethreedifferentclients:Maemo.
Itisthelinux-basedplatformfortheNokiainternettables770andN800.
WeimplementedtheclientusingthePythonscriptinglanguage.
JavaMIDP.
TheJavaMIDPenvironmentrunsonmostmobiledevices.
JavaMIDPsupportstheHTTPprotocolbutnotalltheHTTPactions(onlyGETandPOSTaresupported).
WehaveimplementedasimpleworkaroundforemulatingthePUTandDELETEoperationswithPOST.
WetestedtheclientonaNokiaN73device.
PythonforS60.
S60isNokia'splatformforsmartphonesandmultimediacom-puters.
WehaveimplementedtheclientusingtheportofthePythonlanguageonS60.
TheportprovidesfullsupportforthestandardHTTPlibmodule.
Mash-ups.
WehaveassembledourphotoservicewiththeservicesfromotherInternetsites(e.
g.
Googlemaps)withinthebrowserenvironment.
Themash-upshavebeenimplementedinJavascript.
5.
2MainObservationsOurgeneralevaluationofRESTformobileservicesispositivebuttherearestillsev-erallimitationsthatneedtobesolved.
Welistthemainpointsofourevaluationbelow:RESTwithHTTPprovidesauniformmechanismforbuildingwebservicesthatrequiresaminimalinfrastructureontheclientandtheserversides.
Mostimpor-tantly,thisapproachisindependentoftherun-timeenvironment,aslongasthereisdecentsupportforHTTPasacommondenominator.
Unfortunately,somerun-timelibrariestargetingmobiledevicesstilltreatHTTPasasimpletransportmechanisminsteadofaproperapplicationprotocol.
Forexample,MIMEmulti-partsupportistypicallyprovidedbythemaillibraries,anditsAPIisoftenin-compatiblewithHTTPmessageprocessingAPI,thusrenderingHTTPmultipartmessageparsingratherclumsyandinefficient.
Thenetworklatencyisaconcreteproblemforwebservices,especiallyfortheoveralluserexperienceontheclient-side.
Theuserinterfacerequiresaproperde-signtotakeintoconsiderationthelongroundtripperiodsfortransferringthedataacrossthewirelessnetwork.
Wehaveexperimentedwithtwosolutionsthatcanbeusedforbothreadandwriterequests.
Thefirstoneistoinlineadditionaldatainonerequest(e.
g.
inliningthethumbnails)thatallowsfetchingorupdating.
However,thissolutioninhibitstheindividualHTTPcachingoftheinlinedre-sources.
ThesecondoneistocreateconvenientURIsthatprovidemoreapplica-tion-specificdataeitherbybypassingoraugmentingthecoreAPI,effectivelycreatingcustomviewsontopoftheunderlyingcoreresources.
WhenproperlydesignedintermsofresourcesandtheirURIs,theseviewscanthenbeusedforbatchupdateswithasinglerequest,forexample.
However,thisapproachcompli-catesthedesignoftheback-end,becauseitmayintroducepotentiallycomplexapplication-specificaspectsontheserverside.
DesigningWeb-BasedMobileServiceswithREST449TheJSONdataformatsuitsverywellthemobileenvironment.
Itissimpletogenerate,toparse,andcompacttotransfer.
Accordingtoourpreliminarymeas-urements,however,thesizeofthetransferreddataisnotsignificantlysmallerthanthatofXMLdata,especiallywhenretainingthefieldnamesforself-descriptiveness.
WehavealsoextendedtheJSONformatwithbinarydatatosupporttheresponseinlining,becauseatthemomentwehavefoundthemultipartmessagestoocomplextobeprocessedontheclientside.
DesigningsimpleandintuitiveURIsisacriticalpartoftheRESTdesign.
Wehavesketchedasimpledata-orienteddesignprocessbutweneedamethodforspecifyingtheresourceswithaproperformalism.
EspeciallydeveloperswithoutpriorexperienceofRESTwouldgreatlybenefitfrommethodandtoolsupportthathelpthemmaptheirrequirementstoRESTfulresourcedesign.
Thereisalsotheopenissueofenablingthecomponent-likereuseofresourcesubtreesacrossdifferentpartsoftheAPI(e.
g.
reusingtheTagresourcebetweenthePhotoandVideoresource).
Inoursolution,wedonothaveanyexplicitsupportforofflineprocessing.
OurRESTfulapproach,however,inherentlyfitsmanyofflinescenarios,mainlybe-causeofstatelessness.
Forexample,idempotentrequestscanbequeuedontheclientsidequiteeasilyforlaterdelivery,butthisrequiresthatdynamicallycre-atedresourcesshouldhaveclient-providedURIs.
5.
3"MobileREST"Asexplainedabove,theroundtripcostisprobablythemostsignificantindividualchallengeinnetwork-basedmobileapplications.
Therefore,applyingRESTeffi-cientlyinmobileapplicationarchitecturesmayrequiresomeadditionalconstraintsthatguidethearchitectstomakemoremobile-friendlydecisions.
Theseconstraintswouldprimarilyneedtotacklethedilemmaof"justenoughrequests,justenoughdata".
Inverysimpleterms,"justenoughrequests"referstomechanismsthatgiveclientsenoughcontroltoadjustthescopeoftheRESTfulinteractions,thusreducingtheneedformultiplerequests.
Asanoppositedrivingforce,"justenoughdata"referstomechanismsthatclientsmayusetoadjustthevolumeofdatainasinglemessage.
Elaboratingtheseadditionalconstraintswillbepartofourfuturework.
6ConclusionsThegrowthandsuccessoftheWebmainlyderivefromathoroughapplicationofbasicdesignprinciplesthatarecrystallizedintheRESTstyle.
RESTisalsobecomingapopularparadigmforpublishingWebservices(asanalternativetotheWS-*stack).
InthecurrentpaperwehaveinvestigatedhowtoapplytheRESTprinciplestothedesignofmobileservices.
Wehaveidentifiedseveralissues(likenetworklatencyanddataformats)thatneedparticularattentionwhenapplyingtheRESTconceptstothemobileenvironment.
Fordemonstrationpurposes,wehaveprototypedaRESTphotowebserviceandtesteditwithdifferentmobileclients.
OurpreliminaryevaluationshowsthatRESTwithHTTPprovidesauniformmechanismforbuildingwebser-vicesthatrequiresaminimalinfrastructureontheclient-sideandisindependentof450C.
RivaandM.
Laitkorpitherun-timeenvironment.
Theserviceisextensiblewithdifferentdatarepresentationsand,hence,allowsustoproperlyaddressthemobilespecificneeds.
ThecriticalpartofthedesignprocessistoelaborateaclearURIstructurefortheAPI,allowingmo-bileclientstomakejustenoughrequestsandprocessjustenoughdata.
Wehavefol-lowedadata-drivendesignprocessbutwehavebeenlackingameticulousdesignformalism(e.
g.
,aUMLbasedapproachthathelpsdevelopersmaptheirrequirementstoRESTconstraints).
Ourfutureworkwillbefocusedonimprovingthedesignproc-essofRESTservices,especiallyforthemobileenvironment,andconductamorethoroughevaluationwithadditionalprototypes.
References1.
Fielding,R.
T.
:Architecturalstylesandthedesignofnetwork-basedsoftwarearchitectures,PhDThesis,UniversityofCalifornia,Irvine(2000)2.
Fielding,R.
T.
,Gettys,J.
,Mogul,J.
,Frystyk,H.
,Masinter,L.
,Leach,P.
,Berners-Lee,T.
:HypertextTransferProtocol–HTTP/1.
1.
InternetRFC2616(June1999)3.
Berners-Lee,T.
,Fielding,R.
T.
,Masinter,L.
:UniformResourceIdentifiers(URI):Genericsyntax.
InternetRFC2396(August1998)4.
Thomas,D.
,Hansson,D.
H.
:AgileWebDevelopmentwithRails,PragmaticBookshelf,2ndedn.
(December14,2006)5.
vanGurp,J.
,Karhinen,A.
,Bosch,J.
:MobileServiceOrientedArchitectures.
In:Eliassen,F.
,Montresor,A.
(eds.
)DAIS2006.
LNCS,vol.
4025,pp.
1–15.
Springer,Heidelberg(2006)6.
Freed,N.
,Borenstein,N.
:MultipurposeInternetMailExtensions.
InternetRFC2046(No-vember1996)7.
Nottingham,M.
,Sayre,R.
:TheAtomSyndicationFormat.
InternetRFC4287(December2005)8.
Greogiro,J.
,dehOra,B.
:TheAtomPublishingProtocol,InternetDraftversion17(No-vember2007)9.
Crockford,D.
:Theapplication/jsonMediaTypeforJavaScriptObjectNotation(JSON),InternetRFC4627(July2006)10.
WebServicesArchitecture,W3CWorkingGroupNote(February11,2004),http://www.
w3.
org/TR/ws-arch/11.
SOAP,Version1.
2,W3CRecommendation(Secondedn.
)(April27,2007),http://www.
w3.
org/TR/soap/
HostKvm是一家成立于2013年的国外主机服务商,主要提供VPS主机,基于KVM架构,可选数据中心包括日本、新加坡、韩国、美国、俄罗斯、中国香港等多个地区机房,均为国内直连或优化线路,延迟较低,适合建站或者远程办公等。商家本月针对香港国际机房提供特别7折优惠码,其他机房全场8折,优惠后2G内存香港VPS每月5.95美元起,支持使用PayPal或者支付宝付款。下面以香港国际(HKGlobal)为...
六一云互联六一云互联为西安六一网络科技有限公司的旗下产品。是一个正规持有IDC/ISP/CDN的国内公司,成立于2018年,主要销售海外高防高速大带宽云服务器/CDN,并以高质量.稳定性.售后相应快.支持退款等特点受很多用户的支持!近期公司也推出了很多给力的抽奖和折扣活动如:新用户免费抽奖,最大可获得500元,湖北新购六折续费八折折上折,全场八折等等最新活动:1.湖北100G高防:新购六折续费八折...
近期RAKsmart上线云服务器Cloud Server产品,KVM架构1核1G内存40G硬盘1M带宽基础配置7.59美元/月!RAKsmart云服务器Cloud Server位于美国硅谷机房,下单可选DIY各项配置,VPC网络/经典网络,大陆优化/精品网线路,1-1000Mbps带宽,支持Linux或者Windows操作系统,提供Snap和Backup。RAKsmart机房是一家成立于2012年...
nokia最新手机为你推荐
外网和内网什么是内网,和外网有什么区别金山杀毒怎么样金山杀毒怎么样?照片转手绘有什么软件可以把相片变成手绘的,不是美图秀秀里面的arm开发板ARM开发板和树莓派有什么区别直播加速手机上什么软件可以帮助直播加速,大神们推荐推荐人人逛街为什么女人都喜欢逛街?谢谢了,大神帮忙啊商标注册查询官网怎么查商标是否注册成功宕机何谓宕机?iphone6上市时间苹果6什么时候出?虚拟专用网拨号网络与虚拟专用网的区别
电信主机租用 php主机空间 sharktech hostgator 外国服务器 12306抢票攻略 免费mysql ftp教程 softbank邮箱 phpmyadmin配置 带宽租赁 shuang12 免费的asp空间 成都主机托管 阿里云个人邮箱 网站防护 电信主机托管 hdroad 聚惠网 windowssever2008 更多