Tải bản đầy đủ - 0 (trang)
1 If Web Services Is the Solution, What's the Problem?

1 If Web Services Is the Solution, What's the Problem?

Tải bản đầy đủ - 0trang

partofIBM)thatspecializeinintegration,andproductslikeIBM's

MQSeriesIntegrator,areevidenceofthevibrancyofthisindustry.Itis

business,nottechnology,thatisdrivingtheapplicationintegration

market.Anditisbusiness,nottechnology,thathasdriventhecreationof

Webservices.



32.1.2TheRiseofWebServices

Despiteitsmeteoricrise,Webservicesdidnotappearovernight.Itisthe

resultoftheconvergenceoftrendsinbothapplicationarchitectureand

businessneeds.Aspeoplebegantoassemblelarge-scalesolutions,they

realizedthatmanyofthesamelessonslearnedfromcreatingrobust

softwarecouldbeappliedwhenintegratingtheseapplications.Manyof

theselessonsbecameembodiedinpatterns,likethosedescribedbythe

GangofFour,[1]whileothersbecameestablishedasbestpractices.

Howeverexpressed,thereweretwopatternsthatkeptrecurring.

[1]DesignPatterns,ElementsofReusableSoftware,[Gamma]



Mostfundamentalisthatdistinctbehaviorshouldbeisolated.InOO

languages,wheneachclasshasawell-definedsetof

responsibilities,theresultisanobjectmodelthathasacleanly

factoredsetofinterfaces.Adaptationtonewbusinessrequirements

resultsinminimalimpacttoexistingclasses,reducingthecostof

developmentandtesting.

Thereshouldbealayerofindirectioninplacewhenestablishinga

referencetoanobject.Thereareseveraltechniquesusedto

accomplishthis,manyofthemcoveredintheCreationalPatterns

sectionintheDesignPatternsbook[Gamma].

ThesepatternsarereflectedintheEJBcomponentmodel.Forexample,

atypicalJ2EEimplementationisforbusinessmodelstobeexpressedas

acollectionofstatelesssessionEJBs,withtheirstatepersistedusingan



associatedsetofcontainermanagedEJBs.Byusingtheimplementation

JNDIprovidedwiththeWAS,alongwithEJBhomes,application

developerscanproperlyisolatebusinesslogicasaseparatetierwithin

anapplication.

However,theunderlyingthemesthatthesepatternsaddressarehow

applicationsshouldbecoupled.Previouschapterspresentedindetail

howtobuildaproperlylayeredenterpriseapplication.ThegoalwithWeb

servicesistopresentawell-describedunifiedlogicalviewintothe

businesslayeroftheapplication.



32.1.3ASharedUnderstanding:WhyXML?

Onestepinsolvingtheintegrationproblemistoestablishauniversalway

torepresentstructureddata.TheindustryagreeduponXMLprimarilyfor

tworeasons:(1)XMLisasimple,text-basedmechanismthatallowsdata

tobeexchangedbetweensystemsinastringformat;(2)XMLembraces

thenotionofmetainformation.XMLdocumentsoftenconformtoaXML

Schemadefinition(XSD).ThisXMLSchemaprovidesameanstodefine

thestructure,content,andsemanticsofanXMLdocument.Inthisregard

itplaysaroleverysimilartoaJavaclassinthatitgovernsthestructure

ofitsinstances.Infact,XMLdocumentsthatconformtoaschemaare

saidtobeinstancedocuments.

TheuseofXMLSchemainthismannerallowsthevalidationofdatato

berepresentedexternalofanyprogramminglanguageandplatform.For

example,aschemacandeclarethatitsinstancedocumentswillhavea

tagcalledid,thatitisapositiveInteger,andthatitmustbepresent

inthedocument.Whenthisinstancedocumentisreceived,theXML

parserusestheschemaasameanstovalidateitwithouttheneedto

invokeapplicationlogic.However,thisdoesnoteliminatetheneedfor

applicationvalidationlogic.Forexample,aschemacannotdo

dependencevalidation;thatis,ifthevalueofElementAis100,then

ElementBmustbeeitherXorY.

AsecondadvantagetousingXMLisnamespaces.Acommonproblemis



thatnamesarefrequentlyrepeated;e.g.,id.However,therecouldbe

manydifferentusesofid.Insomesystems,thiscouldbeaninteger,in

others,itisastring.Namespacesprovideanelegantsolutiontothis

problem.UsingJavaagainasareference,anXMLnamespaceislikea

Javapackageinthatitfullyqualifieselements.Therefore,withinone

instancedocumenttwoelementsmayhaveanidenticalnameonlyifthey

areuniquelyqualifiedbydifferentnamespaces.



32.1.4WhatIsaWebService?

Tothispoint,we'vedescribedthebusinessrationaleforWebservices:

applicationintegration.We'vealsodescribedtechnicalissueswith

existingintegrationtechniquesanddistributedcomputingsolutions.But

whatexactlyisaWebserviceandhowdoesitaddresstheseproblems?

HereistheformaldefinitionprovidedinIBM'spaperdefiningthe

conceptualarchitectureofWebservices.



DefiningWebServices

"AWebserviceisaninterfacethatdescribesacollectionofoperationsthatarenetwork

accessiblethroughstandardizedXMLmessaging.Webservicesfulfillaspecifictaskofaset

oftasks.AWebserviceisdescribedusingastandard,formalXMLnotion,calleditsservice

description,thatprovidesallofthedetailsnecessarytointeractwiththeservice,including

messageformats(thatdetailtheoperation),transportprotocols,andlocation."[2]



[2]



http://www.ibm.com/software/solutions/webservices/pdf/WSCA.pdf;pg.6.



ItisthesebasicpropertiesthatgiveWebservicestheflexibilitytobean

effectiveenterpriseintegrationsolution.Businessesexperienceadirect

benefitinadoptingWebservicesbecauseitformalizestheseparationof

interface,implementation,andtransportprotocol.Thus,ratesofchange

canbeeffectivelymanagedbyallowingtheserviceAPItoremain

constantwhiletheunderlyingnetworklocationandimplementation

change.



32.2WebServicesArchitecture

Inordertoachieveintegrationacrossheterogeneousenvironments,

vendorsmustagreeuponhowtoinvoke,describe,andlocateservices.

Traditionally,thesehavebeensomeofthemostdifficultproblemsthat

architectsofdistributedsystemshavehadtosolve.Thissectionexplains

howtheWebservicescommunityhasdefinedacollectionof

specificationsthataddresseachoftheseconcerns,andthenbringsthem

togethertoformaServices-OrientedArchitecture(SOA).



32.2.1TheRoleofSOAP(SimpleObjectAccess

Protocol)

SOAPprovidesanindustrystandardmechanismforXML-based

messaging.BecauseSOAPisXML-based,itisbynatureprogramming

languageandplatformneutral.SOAPwasdesignedtobelightweightand

flexible.Thespecificationdefinesanenvelopingstructurethatcontains

thebusinessinformationwhichisconveyedasanXMLstring.Initial

implementationsofSOAPfavoredencodingbusinessdatainaformat

thatwassuitabletoanRPCstyleofcomputing.SOAPalsosupportsa

document-centricstyleofmessageexchange.Oftenreferredtoasthe

document-literal,thisisnowthepreferredstyleforbusinessdata

transferredwithinaSOAPmessage.

SOAPalsohasprovisionsformessageheadersandfaults.Headers

representinformationthatisorthogonaltothebusinesscontentofthe

message;forexample,securityortransactioninformation.Thefault

mechanismdescribedbythespecificationallowsfortheidentificationof

thesourceoftheerrorandprovidestheabilitytoreturnmeaningful

structureddiagnosticinformation.Becauseofthesefeatures,SOAPhas

emergedasthedefactostandardforXMLmessagingandWebservices.



32.2.2TheRoleoftheWebServicesDescription



Language(WSDL)

WSDListhestandard,formalXMLnotionthatisreferredtoinIBM's

definitionofWebservices.Inmanyaspects,WSDLcanbecomparedto

otherIDLs,inthatitsprimaryresponsibilityistodescribeaninterface.

However,WSDLhasuniquequalitiesandcapabilitiesthatmakeitan

extremelyflexibleandpowerfultool.BecauseWSDLisbaseduponXML,

instancedocumentscanbevalidatedagainstaschemaaswellas

leveragetheflexibilityofnamespaces.Also,descriptiondocumentsare

easilyreadablebyawidevarietyofnonspecializedtools.WSDL

documentscanalsobeseparatedintodistinctsectionsthatisolatethe

argumenttypes,theoperationalinterface,themessageencodingand

transportformat,andtheservicelocation.Infact,thecompleteservice

descriptionneednotbecontainedinasinglephysicaldocument.Rather,

eachsectioncanexistindependentlyasauniquefile.Atruntime,multiple

physicaldocumentscanbecombinedintoonesinglelogicalinterface

definition.

Akeyaspectofconstructingwell-factored,robust,scalableapplicationsis

properlyisolatingtheresponsibilitiesofeachapplicationlayer,then

exposingitthroughawell-definedfaỗade.Whentheseinterfacesare

exposedasservices,WSDListhemechanisminwhichtheyare

described.



32.2.3UDDIandtheProblemofServiceLocation

Fromtheaspectofbuildingdistributedapplications,twoofthe

fundamentalconcernsmessageprotocolanddescriptionhavebeen

addressedwithSOAPandWSDL.Distributedsystemsalsohavea

registrythatprovidesastandardmechanismoflocatingremoteobject

references.Forexample,JavaprovidesJNDI,whichweusedearlierto

getareferencetoourEJBs.Tolocateservicesinaheterogeneous

environment,thereneedstobeamechanismthatfacilitatesthebrowsing

andqueryingofservicedescriptions.



AsWebservicesbegantogainpopularity,vendorssuchasIBMand

Microsoftbeganworkingtogethertodevelopanindustrystandardwayto

locateaservice.Theresultwasaglobalregistry,baseduponthe

standardUniversalDescriptionDiscoveryandIntegration[3]specification.

UDDI,asthisregistryistypicallycalled,iscollectionofreplicatednodes

thatareoperatedbyWebservicesproviderssuchasIBM,Microsoft,and

SAP.ThegoalofUDDIistobenefit"businessesofallsizesbycreatinga

global,platform-independent,openarchitecturefordescribingbusinesses

andservices,discoveringthosebusinessesandservices,andintegrating

businessesusingtheInternet."[4]UDDIallowsbusinessestoclassify

themselvesandtheservicestheyofferbaseduponwell-established

categorizationschemes;e.g.,theNorthAmericanIndustryClassification

System(NAICS)ortheUniversalStandardProductsandServices

Classification(UNPSC).Currently,theoperatorsofthemajorUDDI

nodesdonotchargeforbusinesstousetheregistry.

[3]FordetailedinformationregardingUDDI,pleaseseehttp://www.uddi.org.



[4]



http://www.uddi.org/faqs.html#who.



32.2.4PuttingItAllTogether:TheServiceOrientedArchitecture

SOAP,WSDL,andUDDIarethebuildingblocksfortheWebservices

architecturebyprovidingindustry-standardmechanismsthataddressthe

issuesofmessageprotocol,description,anddiscovery.Together,these

technologiesformthebasisofSOA.Figure32.1isthemostwidelyused

picutureofaSOAasitillustratesthebasicinteractionsoftheprimary

actors.



Figure32.1.TheServices-OrientedArchitecture.



Theinteractionworksasfollows:Serviceprovidersdescribetheir

businessfunctionusingWSDLandpublishittotheserviceregistry;e.g.,

UDDI.Aservicerequestorcanquerytheregistryinordertofindaservice

thatmeetsitsrequirements.Oncefound,theservicerequestorcan

examinethedescriptionandbindtotheserviceinordertoinvokethe

methodsexpressedintheWSDL.Byincorporatingtheserviceregistry,

servicerequestorsareabletogainaccesstotheservicesoftheservice

providerfromanywhereinthenetwork,usingwhateverprotocolis

appropriate.

IBMconsidersanythingtobeaWebservicewhoseinterfacecanbefully

describedinWSDL.Thisencompassesthemorelimiteddefinitions

(requiringSOAPandevenHTTP)thatMicrosoftandSunhewto,butit

alsoencompassestheabilitytouseJMSoverMQSeriesasatransport

layer,oreventochooseJCA(theJ2EEConnectorArchitecture)asa

WebservicesimplementationaswehavedoneinWSAD-IE.

TheconclusiontodrawfromthisdefinitionisthatanSOAisasupersetof

otherdistributedcomputingapproaches;thus,Webservicescanfully

encompasstheJ2EEdistributedcomputingapproachesaswellasthe



emergingonesthatfocusmoretightlyonSOAPandHTTP.Thismeans

thatwecannotonlybaseourWebservicestechnologyonexistingJ2EE

infrastructures,butwecanalsodrawfromourexistingJ2EEbest

practicesandapplythemwithinanSOAcontext.So,whileineffect,

everydistributedserviceinJ2EEisaserviceinthebroadestdefinition,

architecturalprudencehastaughtusthattherearestillplacesunder

whichyouwouldnotwanttousespecificWebservicestechnologiesand

designprinciples.



32.3WebServicesinJ2EE

GiventheroadmapoutlinedbytheSOA,itispossibletomaphowthis

architectureshouldbesupportedrelativetotheJ2EEplatform.To

describethismapping,theJCPintroducedtwostandardsJAX-RPC(JSR101)andJSR-109thatrepresentthecoreinfrastructureofJ2EEbasedWebservices.

TheJAX-RPCspecificationidentifiestheclientandserverprogramming

modelforJ2EEbased-Webservices.Inaddition,isalsodefinesthe

Java-to-WSDLtypemappings.TheJAX-RPCspecificationdefinesthe

coreAPIs,aswellasmappingsfromXML/WSDLtoJavaandJavato

XML/WSDL.ItisthisspecificationthatdefineshowtoolstakeaJava

interfaceandproduceaWSDLdocument.Likewise,aWSDLdocument

canbeconvertedintoasetofJavaclassesthatcan,inturn,beusedto

invokeaservicespecifiedbytheWSDLdocument.

TheWebServicesforJ2EE(JSR-109)specificationcomplementsJAXRPCbyextendingtheprogrammingmodelintotheJ2EEenvironment.

JSR109defineshowJ2EEservicesaretobedeployedintotheruntime

environment.Thisincludesrefinementoftheclientandserver

programmingmodels,thedeploymentmodel,handlersupport,and

WSDLpublicationrules.

Figure33.2illustratestherelationshipsbetweenthespecificationsthat

comprisetheJ2EEWebservicesenvironment.[5]

[5]NotethatalthoughJAX-RPCandJSR109aresupportedbyWAS5.0.2,theyarenot



officiallypartofJ2EEuntilrelease1.4.Likewise,JAXPandSAAJarepresentedherefor

completeness.



Figure32.2.RelationshipbetweenJavaandWebservices

specifications.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

1 If Web Services Is the Solution, What's the Problem?

Tải bản đầy đủ ngay(0 tr)

×