Integrative Programming languaege Module.pdf

shumawakjira26 8 views 37 slides Sep 18, 2025
Slide 1
Slide 1 of 37
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37

About This Presentation

Integrative Programming Module PDF FOR DEGREE PROGRM


Slide Content

IntegrativeProgramming
Page1
CHAPTER1
IntroductiontoIntegrativeProgramming&Technologies
CourseLearningOutcome:
Attheendofthesemester,thestudentswillbeableto:
1.DiscusstheIntroductiontoIntegrativeProgrammingandTechnologies;
2.Explainintegrativetechnologiesormethodsusedinapplicationintegration;and
3.Evaluatethedifferenttypesofmiddlewareandhowthemiddlewaresolvesproblemof
heterogeneity.
Definition:
Integrationofsoftwarereferstotechniquesforcombiningexistingsoftware
componentstoformacompletesystem.
However,thesoftwareintegrationincludesatleastoneexistingsoftwaresystem,
developedinthepastwithnoplanforitssymmetricintegrationwithanother
componentinthefuture.
Integrativeprogrammingdealswithanintegrationapproachesandtechniquesthat
connectdifferentcomponentsofITinfrastructure-
People,
Applications,
Platformsand
Databasestoenableasecure,intraandinterapplicationcollaboration.
Integrativesolutionsenableanorganizationtointegratebusinessprocessesinternallyand
externallywithbusinesspartnerstocreatedynamicenvironmentsthatsupportscurrent
andevolvingbusinessrequirements,therebycreatingaglobalorganization.
Applicationintegrationassistsinunlimitedsharingofdataandbusinessprocesses
amonganyconnectedapplicationsordatasourcesinwithoutmakingmajorchanges
totheapplicationsordatastructures.
Integrationistheprocessofconnectingmultiple,independentlydevelopedapplications
usingincompatibletechnologiesintoasingleorganizationwidesystemwithinformation
flowingseamlesslyamongtheintegratedsystemsorcomponents.

IntegrativeProgramming
Page2
Mostoftheapplicationsthatruninorganizations’hardlyliveinisolation.
Whethertheregistrarapplicationmustinterfacewiththefinanceapplication,
thehumanresourcemanagementapplicationmustconnecttoeachother,it
seemslikeanyapplicationcanbemadebetterbyintegratingitwithother
applications.
Integrationofmultiple,independentlydeveloped,managedandmaintainedapplications
componentsthatmaynormallyuseincompatibletechnologiesandheterogeneous
platforms”
Enablestransmissionofinformationbetweenapplications,
Automatesflowofdatabetweenapplicationsthatmakeupthebusinessprocessflow.
Integrationistheprocessofcombiningseparateapplicationsintocooperating
collectionsofapplication.
Overviewofintersystemcommunication
Inter-systemcommunicationisthecommunicationbetweenasetofheterogeneous
systemsthatareintegratedtogether.
Theseintegratedsystemswhichputtogethermanyheterogeneoussetof
subsystemsandtheproducedobjectsareextremelydifferent,yetshould
contributetothesameprocess.
Softwareintegrationincludesoneormoreofthefollowing.
1.Systemintegration
Giventwoormoresystems,subsystemsorcomponents,eachofwhichfunction
properly(satisfyingtheirrequirementwithintheirenvironment).
Theproblemistointegratethemintoonelargersystemsatisfyingthecombined
requirementswithinthenewlyformedenvironment.
2.Functionalintegrationortechnologyintegration
Givenasoftwaresystem,thismayhavebeenfunctioningproperlyinthefieldfora
significantperiod.
Theproblemistointegrateanewfunctionoranewtechnologywithinthesystem.
Theintegratedsystemshouldprovidethenewfunctionalityorusethenew
technology,whilepreservingtheoriginalsystemfunctionality.

IntegrativeProgramming
Page3
3.Incrementalengineering
Asoftwaresystemcanbedevelopedanddeliveredusingavailabletechnologiesand
withlessfunctionalitythanitisintendedtofinallyprovide.
Newtechnologiesandormorefunctionsthencanbeintegratedwithinthesystem.
Theproblemistodesignthesystemwithsuchfutureintegrationinmind.
4.Modification
Sometimesanexistingandproperlyfunctioningsoftwaresystemmustbe
decomposedandintegratedtocarryoutmodification.
Theneedforintegration
Mostoforganizationsconsistofmorethanonedepartment,runningdepartment
specificapplicationsandthoseapplicationsinteractwitheachothertoachievethe
overallobjectiveoftheorganizations.
Informationsystemschangeovertimebygrowingintheirsize,incorporating
functionalityoftheexistingstandalonesystems.
Applicationsoriginallyintendedtooperateseparately,lateronarerequiredto
interoperatewithothers.
Someofthereasonsforintegrationarethefollowing;
•Technologychangeaffectsalllayers;legacydoesnotgoawaysoeasily.
•Thearchitectureoftheorganizationinformationsystemdependsonconstraints
relatedtothetechnologybutalsototheorganization.
•Withinanenterprise,eachdepartmentmayhaveitsownITinfrastructure,
systemsanddatabaseswhicharemaintainedindependently.
Integratingthemmaybringadditionalvaluetothecompany.
•IntegrationassistsinformationofZeroLatencyorganization-whenall
functionswithintheorganizationworkwiththesameup-to-dateinformation,
latencybetweenapplicationsiseliminated/reduced.
•Updatingandintegratingofapplicationsispossiblewheneverrequired.New
applicationscanbecreatedbyintegratingrealtimedatafromdifferentpartsof
theenterprise

IntegrativeProgramming
Page4
Integrationmodels
Integrationmodeldefineshowapplicationswillbeintegratedbydefiningthenature
ofandmechanismsforintegration.
Someofthemethodsusedforapplicationintegrationarediscussedinthefollowing
section.Thesemodelsinclude;
1.Presentationintegration
2.Dataintegrationand
3.Functionintegration
1.Presentationintegrationmodel
Allowstheintegrationofnewsoftwarethroughtheexistingpresentationsofthe
legacysoftware.
Thisistypicallyusedtocreateanewuserinterfacebutmaybeusedtointegrate
withotherapplications.
2.Dataintegrationmodel
Allowstheintegrationofsoftwarethroughaccesstothedatathatiscreated,
managedandstoredbythesoftwaretypicallyforthepurposesofreusingor
synchronizingdataacrossapplications.
3.Functionalintegrationmodel
Allowstheintegrationofsoftwareforthepurposeofinvokingexisting
functionalityfromotherneworexistingapplications.
Theintegrationisdonethroughinterfacestothesoftware.
FundamentalChallengesofIntegration
Tosupportcommonbusinessprocessesanddatasharingacrossapplications,these
applicationsneedtobeintegrated.
Applicationintegrationneedstoprovideefficient,reliableandsecuredataexchange
betweenmultipleenterprisesapplications.
AlotoftheproblemstobeaddressedinOrganizationsApplicationIntegrationsystem
fromhavingtointegratestandaloneapplicationswhichhavebeen

IntegrativeProgramming
Page5
Developedindependently,
Operateautonomously,and
Werenotoriginallyindentedtobeintegratedwithoneanother.
Integrationofapplications,developedbydifferentlanguagesandrunningondifferent
computingplatformsisnotaneasytask.
Bydefinition,integrationhastodealwithmultipleapplicationsrunningonmultiple
platformsindifferentlocations,makingtheterm‘simpleintegration’prettymuch
difficult.
Softwarevendorsofferapplicationintegrationsuitesthatprovidecross-platform,cross-
languageintegrationaswellastheabilitytointerfacewithmanypopularpackaged
businessapplications.
However,thistechnicalinfrastructurepresentsonlyasmallportionofthe
integrationcomplexities.
Thetruechallengesofintegrationspanfaracrossbusinessandtechnicalissues.
Allintegrationsolutionshavetodealwithafewfundamentalchallenges:someofthe
challengesofintegrationare;
Networkunreliability
Distributedsystems
Slownetworksand
Heterogeneity
Modificationcomplexity
1.Networkisunreliable.
Integrationsolutionshavetotransportdatafromonecomputertoanotheracross
networks.
Comparedtoaprocessrunningonasinglecomputer,distributedcomputinghas
tobepreparedtodealwithamuchlargersetofpossibleproblems.
Oftentimes,twosystemstobeintegratedareseparatedbycontinentsanddata
betweenthemhastotravelthroughphone-lines,LANsegments,routers,
switches,publicnetworks,andsatellitelinks.
Eachofthesestepscancausedelaysorinterruptions.

IntegrativeProgramming
Page6
2.Distributed–
Intheworstcase,everyapplicationrunsonacompletelyseparateenvironment,
E.g.databasestorageisnotsharedamongapplications.
Message-basedcommunicationistheonlypossibilitytoexchangeinformation.
3.Networksareslow.
Sendingdataacrossanetworkismultipleordersofmagnitudeslowerthan
makingalocalmethodcall.
Designingawidelydistributedsolutionthesamewayyouwouldapproacha
singleapplicationcouldhavedisastrousperformanceimplications
4.Anytwoapplicationsaredifferent.
Integrationsolutionsneedtotransmitinformationbetweensystemsthatuse
differentprogramminglanguages,operatingplatforms,anddataformats.
Anintegrationsolutionneedstobeabletointerfacewithallthesedifferent
technologies.
Heterogeneous–eachapplicationimplementsitsowndatamodel.
Conceptsmaybeshared,butrepresentationmismatchesaretobeexpected.
Mappingsandtransformationsarerequired.
5.Changeisinevitable.
Applicationschangeovertime.
Anintegrationsolutionhastokeeppacewithchangesintheapplicationsit
connects.
Integrationsolutionscaneasilygetcaughtinanavalancheeffectofchanges–if
onesystemchanges,allothersystemsmaybeaffected.
Anintegrationsolutionneedstominimizethedependenciesfromonesystemto
anotherbyusingloosecouplingbetweenapplications.
Autonomous–applicationsupdatetheirstateindependentlywithoutcoordinating
witheachother.

IntegrativeProgramming
Page7
Thesystemstobeintegratedaremaintainedindependentlyandupgradedat
differenttimes.
IntegrativeTechnologies/methodsforintegration
Applicationintegrationisanintegrationframeworkcomposedofacollectionof
technologiesandserviceswhichformamiddlewareor"middlewareframework"to
enableintegrationofsystemsandapplicationsacrossorganizations.
Therearefourmethodsusedinapplicationintegration,whicharediscussedinthesection
below:
1.FileTransfer-
Oneapplicationwritesafilethatanotherlaterreads.
Theapplicationsneedtoagreeonthefilenameandlocation,theformatofthe
file,thetimingofwhenitwillbewrittenandread,andwhowilldeletethefile.
2.SharedDatabase-
Multipleapplicationssharethesamedatabaseschema,locatedinasingle
physicaldatabase.
Becausethereisnoduplicatedatastorage,nodatahastobetransferredfrom
oneapplicationtotheother.
3.RemoteProcedureInvocation–
Oneapplicationexposessomeofitsfunctionalitysothatitcanbeaccessed
remotelybyotherapplicationsasaremoteprocedure.
Thecommunicationoccursreal-timeandsynchronously.
4.Messaging–
Oneapplicationpublishesamessagetoacommonmessagechannel.
Otherapplicationscanreadthemessagefromthechannelatalatertime.
Theapplicationsmustagreeonachannelaswellastheformatofthemessage.
Thecommunicationisasynchronous(onebyonecommunication)example
usingATMmachine.
Allofthefourapproachessolveessentiallythesameprobleminintegration;
eachstylehasitsdistinctadvantagesanddisadvantages.

IntegrativeProgramming
Page8
Infact,applicationsmayintegrateusingmultiplestylessuchthateachpointof
integrationtakesadvantageofthestylethatsuitsitbest.
Filetransfer
Anorganizationnaturally,runsmultipleapplicationsthatarebeingbuilt
independently,withdifferentlanguagesandplatforms.
Howcanweintegratemultipleapplicationssothattheyworktogetherandcanexchange
informationandinteractwitheachother?Theanswerforthisquestionisgivenbelow;
Oneofthepossiblesolutionstoallowtheseapplicationstobeintegratedis
allowingeachapplicationproducefilescontaininginformationthatother
applicationsneedtoconsume.
Integratorstaketheresponsibilityoftransformingfilesintodifferentformats.
Producethefilesatregularintervalsaccordingtothenatureofthebusiness,
whichcanbeconsumedorreadbyanotherfile.
Animportantdecisionwithfilesiswhatformattouse.
Veryrarelywilltheoutputofoneapplicationbeexactlywhat'sneededfor
another,soyou'llhavetodoafairbitofprocessingoffilesalongtheway.
Notjustdoalltheapplicationsthatuseafilehavetoreadit,youalsohavetobeableto
useprocessingtoolsonit.
SharedDatabase
Acommondatabasecanbeusedforintegratingapplications.
Asinglephysicaldatabasecanbesharedbydifferentapplicationsrunningondifferent
platforms.

IntegrativeProgramming
Page9
Thismethodintegratesapplicationsbyhavingthemstoretheirdatainasingleshared
database.
Ifafamilyofintegratedapplicationsallrelyonthesamedatabase,thenwecanbepretty
surethattheyarealwaysconsistentallofthetime.
Ifwedogetsimultaneousupdatestoasinglepieceofdatafromdifferentsources,then
wehavetransactionmanagementsystemsthathandlethataboutasgracefullyasitever
canbemanaged.
Remoteprocedurecalls
Thismethoddevelopseachapplicationwhichisrequiredtobeintegratedasalarge-
scaleobjectorcomponentwithencapsulateddataanditprovidesaninterfaceto
allowotherapplicationstointeractwiththerunningapplication.
RemoteProcedureInvocationappliestheprincipleofencapsulationtointegrating
applications.
oIfanapplicationneedssomeinformationthatisownedbyanotherapplication,it
asksthatapplicationdirectly.
oIfoneapplicationneedstomodifythedataofanother,thenitdoessobymakinga
calltotheotherapplication.
oEachapplicationcanmaintaintheintegrityofthedataitowns.

IntegrativeProgramming
Page10
Furthermore,eachapplicationcanalteritsinternaldatawithouthavingeveryother
applicationbeaffected.
Messaging
Messagingallowsinteractionbetweenapplicationspossible.
Messagepassingcanbeusedtotransferpacketsofdatafrequently,immediately,
reliably,andasynchronously,orsynchronouslyusingcustomizableformats.
Asynchronousmessagingisfundamentallyapracticalreactiontotheproblemsof
distributedsystems.
Sendingamessagedoesnotrequirebothsystemstobeupandreadyatthe
sametime.
Furthermore,thinkingaboutthecommunicationinanasynchronousmanner
forcesdeveloperstorecognizethatworkingwitharemoteapplicationisslower,
whichencouragesdesignofcomponentswithhighcohesion(lotsofworklocally)
andlowadhesion(selectiveworkremotely).
Thereasonamessagingsystemisneededtomovemessagesfromonecomputerto
anotheristhatcomputersandthenetworksthatconnectthemareinherentlyunreliable.
Justbecauseoneapplicationisreadytosendacommunicationdoesnotmeanthat
theotherapplicationisreadytoreceiveit.
Evenifbothapplicationsareready,thenetworkmaynotbeworking,ormayfailto
transmitthedataproperly.
Amessagingsystemovercomestheselimitationsbyrepeatedlytryingtotransmitthe
messageuntilitsucceeds.

IntegrativeProgramming
Page11
Underidealcircumstances,themessageistransmittedsuccessfullyonthefirsttry,but
circumstancesareoftennotideal.
Inessence,amessageistransmittedinfivesteps:
1.Create-thesendercreatesthemessageandpopulatesitwithdata.
2.Send-thesenderaddsthemessagetoachannel.
3.Deliver-themessagingsystemmovesthemessagefromthesender’scomputerto
thereceiver’scomputer,makingitavailabletothereceiver.
4.Receive-thereceiverreadsthemessagefromthechannel.
5.Process-thereceiverextractsthedatafromthemessage.
Thisdiagramillustratesthesefivetransmissionsteps,whichcomputerperformseach,and
whichstepsinvolvethemessagingsystem:
Thisdiagramalsoillustratestwoimportantmessagingconcepts:
1.Sendandforget–
Instep2,thesendingapplicationsendsthemessagetothemessagechannel.
Oncethatsendiscomplete,thesendercangoontootherworkwhilethe
messagingsystemtransmitsthemessageinthebackground.

IntegrativeProgramming
Page12
Thesendercanbeconfidentthatthereceiverwilleventuallyreceivethe
messageanddoesnothavetowaituntilthathappens.
2.Storeandforward–
Instep2,whenthesendingapplicationsendsthemessagetothemessagechannel,
themessagingsystemstoresthemessageonthesender’scomputer,eitherin
memoryorondisk.
Instep3,themessagingsystemdeliversthemessagebyforwardingitfromthe
sender’scomputertothereceiver’scomputer,andthenstoresthemessageonce
againonthereceiver’scomputer.
Thisstore-and-forwardprocessmayberepeatedmanytimes,asthemessageis
movedfromonecomputertoanother,untilitreachesthereceiver’scomputer.
MiddlewareandIntegrativearchitectures
Middlewareisasoftwareprogrammingrunningatthetopofoperatingsystemand
belowtheapplications.
Itconnectsapplicationsorsoftwarecomponents.
Middlewareprovidesastandardhighlevelinterfacetotheapplicationdevelopers
andintegrators,sothatapplicationcaneasilyinteroperate.
Interoperabilityistheabilityoftwoormorecomponentsorsystemstoexchange
information.

IntegrativeProgramming
Page13
Therearethreetypesofmiddleware.Theseare,transaction-oriented,object-oriented
andmessageorientedmiddleware.
1.Transaction-orientedmiddleware:supportsdistributedcomputinginvolving
databaseapplications.
2.Message-orientedmiddleware:supportsreliable,asynchronous
communicationsbetweendistributedcomponentsorapplications.
3.Object-orientedmiddleware:systemsarebasedonobject-orientedparadigm,
andprimarilysupportsynchronouscommunicationsbetweendistributedobjects
orsoftwarecomponents.ExamplesareCORBA,DCOMandRMI.
Integrativearchitectures
Integrativearchitecturesarethestandardmethodologiesforapplicationintegration.
Thesearchitecturesinclude,CORBA,DCOMandRPC.
Thearchitecturesactasamiddleware,asoftwareapplicationthatmediatesbetween
differentapplications.
CommonObjectRequestBrokerArchitecture
CORBAisasoftwarestandardthatisdefinedandmaintainedbytheObjectManagement
Group(OMG).
TheCommonObjectRequestBrokerArchitecture(CORBA)isastandardarchitecture
foradistributedobjectssystem.
CORBAisdesignedtoallowdistributedobjectstointeroperateinaheterogeneous
environment,whereobjectscanbeimplementedindifferentprogramminglanguage
and/ordeployedondifferentplatforms.

IntegrativeProgramming
Page14
DCOM
Distributedcomponentobjectmodel-extendstheCOMtosupportcommunication
betweenobjects.
DCOMisasoftwarearchitectureorremoteprotocolthatdefinesabinarystandardfor
componentinteroperability.
DCOMisasoftwarearchitecturethatallowsapplicationstobebuiltfrombinarysoftware
components.
Isbinaryinterfacestandardforsoftwarecomponents,thatallowsinter-process
communication.
Binaryinterfaceisaprograminterfacebetweenbinaryprogrammodulesoftenoneofthe
moduleislibraryoroperatingsystemandtheotherisuserprogrammodule.
Defineshowcomputationalroutinesarecalledinmachinecodeorlow-levelwhichis
hardwareindependent

IntegrativeProgramming
Page15
ReviewQuestions
1.Defineintegrativeprogramming?
2.Explainthearchitecturesusedinapplicationintegration?
3.Describeinteroperability?
4.Whatarethechallengesinapplicationintegrationdescribethesolutionsto
overcomethechallenges?
5.DescribethedifferencebetweenCORBAandRMIorremotemethodinvocation?
6.Explainintegrativetechnologiesormethodsusedinapplicationintegration?
7.Whatisthedifferencebetweendatalevelandfunctionlevelintegrationmodel?
Whichmodelismorecomplexandwhy?
8.Whatisheterogeneity?
9.Describedifferenttypesofmiddlewareanddescribehowthemiddlewaresolves
problemofheterogeneity?

IntegrativeProgramming
Page16
CHAPTER2
WebServicesandMiddleware;Networkprogramming;Lowleveldata
communicationsMessageandqueuingservices
CourseLearningOutcome:
Attheendofthesemester,thestudentswillbeableto:
1.DescribetheWebServicesandMiddleware;
2.IdentifythepartsofNetworkProgramming;and
3.Modifyalowleveldatacommunicationsmessageandqueuingservices.
WebServicesandMiddleware
Applicationintegrationtechnology
Allowsapplicationstobeintegratedmorerapidly,easilyandlessexpensively.
Program-to-programinteractionswhereaswebforprogram-to-userinteractions.
Allowcompaniestoreducethecostofdoinge-business,todeploysolutionsfasterand
toopenupnewopportunities.
Webservicesmodelbuiltonemergingstandardssuchas
HTTP
XML
SimpleObjectAccessProtocol(SOAP)
WebServicesDescriptionLanguage(WSDL)
UniversalDescription,DiscoveryandIntegration(UDDI)
Developedinordertodistributeanobjectandserveittovarioususersintheweb
environments.
Usedintheserversituationswhilesolvingtheweb-scalabilityproblemoftheother
distributedobjecttechnologies.
WSDLandSOAPexploitXML.
WSDLisanXMLdescribingthewebservice.
SOAPisanXMLdescribingthecalledmethod,itsparameters,anditsreturnvalue,
canbedeliveredovertheHTTP

IntegrativeProgramming
Page17
WebServicesandMiddleware
1.Aclientthatwantstobeservicedshouldfirstfindthesupportedservicesfromthepre-
existingregistrybeforecompilingacode.
2.Afterfindingitsservicesthroughsearching,theclientgainstheWebService
DescriptionLanguage(WSDL)thataserverpreviouslyregisters.
FromtheWSDL,theclientknowstheserviceproviderlocationandthe
parameterstothefoundmethod.
3.Aftertheclientbindsthedescribedserviceduringthecompiletime,itcallsthelocal
agentwhenevertheclientinvokesamethodcall,andthelocalagentdeliversittothe
serversideagentthroughSimpleObjectAccessProtocol(SOAP)overHTTP,FTP,
SMTP,andTCPduringtheruntime.
4.Theserversideagentactivatestheappropriateobject,anddeliversthecallstotheobject.
NetworkProgramming
Network:
Anetworkisacollectionofcomputersandotherdevicesthatcansenddatatoand
receivedatafromeachother.

IntegrativeProgramming
Page18
Anetworkisoftenconnectedbywires.
However,wirelessnetworkstransmitdatathroughinfraredlightand
microwaves.
Node:
Eachmachineonanetworkiscalledanode.
Mostnodesarecomputers,butprinters,routers,bridges,gatewaysetc.canalso
benodes.
Nodesthatarefullyfunctionalcomputersarealsocalledhosts.
Packet:
Allmoderncomputernetworksarepacket-switchednetworks:datatravelingon
thenetworkisbrokenintochunkscalledpacketsandeachpacketishandled
separately.
Eachpacketcontainsinformationaboutwhosentitandwhereit'sgoing.
Protocol:
Aprotocolisaprecisesetofrulesdefininghowcomputerscommunicate:the
formatofaddresses,howdataissplitintopackets.
IP:
IPwasdesignedtoallowmultipleroutesbetweenanytwopointsandtoroute
packetsofdataarounddamagedrouters.
TCP:
Sincetherearemultipleroutesbetweentwopointsandthepacketsthatmakeupa
particulardatastream.
Furthermore,theymaynotarriveintheordertheyweresent,iftheyevenarriveat
all.
UDP:
UDPisunreliableprotocolsthatdoesnotguaranteethatpacketswillarriveat
theirdestinationorthattheywillarriveinthesameordertheyweresent.
Ports:
EachcomputerwithanIPaddresshasseveralthousandlogicalports.
Eachportisidentifiedbyanumberbetween1and65,535.

IntegrativeProgramming
Page19
Eachportcanbeallocatedtoaparticularservice.
Portnumbers1through255arereservedbyIPforwell-knownservices.
Ifyouconnecttoport80ofahost,forinstance,youmayexpecttofindanHTTP
server.
Internet:
LargestIP-basednetworkforconnectingmachinestogether.
Java:easy-to-use,cross-platformmodelfornetworkcommunications.
WhatisaSocket?
SocketsareameansofusingIPtocommunicatebetweenmachines,sosocketsallow
Javatointeroperatewithlegacysystemsbysimplytalkingtoexistingserversusingtheir
pre-definedprotocol.
Internetprotocol:UserDatagramProtocol(UDP)andTransmissionControlProtocol
(TCP).
InternetAddressesorIPAddresses
Everynetworknodehasanaddress,aseriesofbytesthatuniquelyidentifyit.
InternetaddressesaremanipulatedinJavabytheuseoftheInetAddress
class.InetAddresstakescareoftheDomainNameSystem(DNS)look-upand
reverselook-up;
IPaddressescanbespecifiedbyeitherthehostnameortherawIPaddress.
InetAddressprovidesmethodstogetByName(),getAllByName(),getLocalHost(),
getAddress(),etc.
IPaddressesarea32-bitnumber,oftenrepresentedasa"quad"offour8-bitnumbers
separatedbyperiods.
Theyareorganizedintoclasses(A,B,C,D,andE).
Forexample126.255.255.255Client/ServerComputing-Javalanguage
communicatewithremotefilesystem.
HowUDPclientsandUDPserverscommunicateoversocketsCreatingUDP
Servers:
TocreateaserverwithUDP,dothefollowing:
1.CreateaDatagramSocketattachedtoaport.

IntegrativeProgramming
Page20
intport=1234;
DatagramSocketsocket=newDatagramSocket(port);
2.Allocatespacetoholdtheincomingpacket,andcreateaninstanceof
DatagramPackettoholdtheincomingdata.
byte[]buffer=newbyte[1024];
DatagramPacketpacket=newDatagramPacket(buffer,buffer.length);
3.Blockuntilapacketisreceived,thenextracttheinformationyouneedfromthe
packet.
//Blockonreceive()
socket.receive(packet);
//Extractthepacketdata
byte[]data=packet.getData();
//Findoutwherepacketcamefrom
//sowecanreplytothesamehost/portInetAddressremoteHost=
packet.getAddress();intremotePort=packet.getPort();
CreatingUDPClients
1.Firstallocatespacetoholdthedatawearesendingandcreateaninstanceof
DatagramPackettoholdthedata.
byte[]buffer=newbyte[1024];
intport=1234;
InetAddresshost=InetAddress.getByName("magelang.com");
DatagramPacketpacket=newDatagramPacket(buffer,buffer.length,host,
port);
2.CreateaDatagramSocketandsendthepacketusingthissocket.
DatagramSocketsocket=newDatagramSocket();//freelocalporttouse
socket.send(packet);
//FindoutwherewearesendingfromInetAddresslocalHostname=
socket.getLocalAddress();intlocalPort=socket.getLocalPort();
HowTCPclientsandTCPserverscommunicateoversocketsCreatingTCPServers:
TocreateaTCPserver,dothefollowing:
1.CreateaServerSocketattachedtoaportnumber.

IntegrativeProgramming
Page21
ServerSocketserver=newServerSocket(port);
2.Waitforconnectionsfromclientsrequestingconnectionstothatport.
//Blockonaccept()
Socketchannel=server.accept();
You'llgetaSocketobjectasaresultoftheconnection.
3.Getinputandoutputstreamsassociatedwiththesocket.
out=newPrintWriter(channel.getOutputStream());out.println("Hey!I
heardyouoverthissocket!");
reader=newInputStreamReader(channel.getInputStream());in=new
BufferedReader(reader);
Nowyoucanreadandwritetothesocket,thus,communicatingwiththeclient.
Stringdata=in.readLine();
CreatingTCPClients:
TocreateaTCPclient,dothefollowing:
1.CreateaSocketobjectattachedtoaremotehost,port.
Socketclient=newSocket(host,port);
Whentheconstructorreturns,youhaveaconnection.
2.Getinputandoutputstreamsassociatedwiththesocket.
out=newPrintWriter(client.getOutputStream());out.println("Watson!"+
"Comehere...Ineedyou!");
reader=newInputStreamReader(client.getInputStream());in=new
BufferedReader(reader);
Nowyoucanreadandwritetothesocket,thus,communicatingwiththeserver.
Stringdata=in.readLine();
LowLevelDataCommunication
TCP/IP(TransmissionControlProtocol/InternetProtocol)
oTheProtocoluponwhichthewholeInternetisbased
oEachnodemustbeconfiguredforTCP/IPtofunctionproperly.
oAsoftware-basedprotocol
oTCP/IPisbasicallythebindingtogetherofInternetProtocolsusedtoconnect
hostsontheinternet-MainonesareIPandTCP

IntegrativeProgramming
Page22
oTCPandIPhavespecialpacketstructure
oIP(InternetProtocol)isresponsiblefordeliveringpacketsofdatabetweensystems
ontheinternetandspecifiestheirformat.Packetsforwardedbasedonafourbyte
destinationIPaddress(IPnumber)IPDOESNOTMAKEGUARANTEES!Itis
verysimple-essentially:sendandforget.
oTCP(TransmissionControlProtocol)isresponsibleforverifyingthecorrect
deliveryofdata/packetsfromclienttoserver.Datacanbelost.SoTCPalsoadds
supporttodetecterrorsandretransmitdatauntilcompletelyreceived.
IPPacketStructure
Version-IndicatestheversionofIPcurrentlyused.
IPHeaderLength(IHL)-Indicatesthedatagramheaderlengthin32-bitwords.
Type-of-Service-Specifieshowanupper-layerprotocolwouldlikeacurrentdatagram
tobehandled,andassignsdatagramvariouslevelsofimportance.

IntegrativeProgramming
Page23
TotalLength-Specifiesthelength,inbytes,oftheentireIPpacket,includingthedataand
header.
Identification-Containsanintegerthatidentifiesthecurrentdatagram.Thisfieldis
usedtohelppiecetogetherdatagramfragments.
Flags-Consistsofa3-bitfieldofwhichthetwolow-order(least-significant)bitscontrol
fragmentation.Thelow-orderbitspecifieswhetherthepacketcanbefragmented.The
middlebitspecifieswhetherthepacketisthelastfragmentinaseriesoffragmented
packets.Thethirdorhigh-orderbitisnotused.
FragmentOffset-Indicatesthepositionofthefragment’sdatarelativetothebeginningof
thedataintheoriginaldatagram,whichallowsthedestinationIPprocesstoproperly
reconstructtheoriginaldatagram.
Time-to-Live-Maintainsacounterthatgraduallydecrementsdowntozero,atwhich
pointthedatagramisdiscarded.
Protocol-Indicateswhichupper-layerprotocolreceivesincomingpacketsafterIP
processingiscomplete.
HeaderChecksum-HelpsensureIPheaderintegrity.
SourceAddress-Specifiesthesendingnode.
DestinationAddress-Specifiesthereceivingnode.
Options-AllowsIPtosupportvariousoptions,suchassecurity.
Data-Containsupper-layersentinpacket.
TCPPacketStructure

IntegrativeProgramming
Page24
Thereare12fieldsinTCPPacket:
SourcePortandDestinationPort-Identifiespointsatwhichupperlayersource
anddestinationprocessesreceiveTCPservices.
SequenceNumberIntheconnection-establishmentphase,thisfieldalsocanbe
usedtoidentifyaninitialsequencenumbertobeusedinanupcoming
transmission.
AcknowledgmentNumber-Containsthesequencenumberofthenextbyteof
datathesenderofthepacketexpectstoreceive.
DataOffset-Indicatesthenumberof32-bitwordsintheTCPheader.
Reserved-Remainsreservedforfutureuse.

IntegrativeProgramming
Page25
Flags-Carriesavarietyofcontrolinformation,includingtheSYNandACKbits
usedforconnectionestablishment,andtheFINbitusedforconnection
termination.
Window-Specifiesthesizeofthesender’sreceivingwindow(thatis,thebuffer
spaceavailableforincomingdata).
Checksum-Indicateswhethertheheaderwasdamagedintransit.
UrgentPointer-Pointstothefirsturgentdatabyteinthepacket.
Options-SpecifiesvariousTCPoptions.
Data-Containsupper-layersentinpacket.

IntegrativeProgramming
Page26
Chapter3
DataMappingandExchange
CourseLearningOutcome:
Attheendofthesemester,thestudentswillbeableto:
1.DiscussDataMappingandExchange;
2.DefineaComplexElementusingXMLScheme;and
3.CreateXMLSchemasbyUsingXMLSchema-CreationTools.
XMLDTDandXMLSchema
HowdoesanXMLprocessorcheckyourxmldocument?
TherearetwomainchecksthatXMLprocessorsmake:
1.Checkingthatyourdocumentiswell-formed(Syntaxrule)
2.Checkingthatit'svalid(syntax-checkyourXMLeitherinXMLDTDorXSD)
DTD-DocumentTypeDefinition
XSD-XMLSchemaDefinition
WhyneedXMLValidator
UseourXMLvalidatortosyntax-checkyourXML.
ErrorsinXMLdocumentswillstopyourXMLapplicationsunlikeHTMLbrowser
XMLDTD
AnXMLdocumentwithcorrectsyntaxiscalled"WellFormed".
AnXMLdocumentvalidatedagainstaDTDis"WellFormed"and"Valid".
ThepurposeofaDTDistodefinethestructureofanXMLdocumentandalistof
legalelements.
HowyouaddaDTDtoourXMLdocument
1.DTDscanbeseparatedocuments(or)
2.TheycanbebuiltintoanXMLdocumentusingaspecialelementnamed<!DOCTYPE>.
AnXMLDocumentwithaDTD(example4.xml)
<?xmlversion="1.0"encoding="UTF-8"?>
<?xml-stylesheettype="text/css"href="css1.css"?>

IntegrativeProgramming
Page27
<!DOCTYPEdocument
[
<!ELEMENTdocument(heading,message)>
<!ELEMENTheading(#PCDATA)>
<!ELEMENTmessage(#PCDATA)>
]>
<document>
<heading>HelloFromXML</heading>
<message>ThisisanXMLdocument!</message>
</document>
ValidXMLDocumentwithDTD(example.5.xml)
TheDOCTYPEdeclarationisareferencetoanexternalDTDfile"Note.dtd“
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEnoteSYSTEM"Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don'tforgetmethisweekend!</body>
</note>
Note.dtd
<!DOCTYPEnote[
<!ELEMENTnote(to,from,heading,body)>
<!ELEMENTto(#PCDATA)>
<!ELEMENTfrom(#PCDATA)>
<!ELEMENTheading(#PCDATA)>
<!ELEMENTbody(#PCDATA)>
]>
TheDTDaboveisinterpretedlikethis:
!DOCTYPEnotedefinesthattherootelementofthedocumentisnote

IntegrativeProgramming
Page28
!ELEMENTnotedefinesthatthenoteelementcontainsfourelements:"to,from,
heading,body"
!ELEMENTtodefinesthetwoelementtobeoftype"#PCDATA"
!ELEMENTfromdefinesthefromelementtobeoftype"#PCDATA"
!ELEMENTheadingdefinestheheadingelementtobeoftype"#PCDATA"
!ELEMENTbodydefinesthebodyelementtobeoftype"#PCDATA“
Note
#PCDATAmeansparse-abletextdata.
WhenNOTtoUseaDocumentDefinition?
WhenyouareworkingwithsmallXMLfiles,creatingdocumentdefinitionsmaybea
wasteoftime.
XMLSchema
AnotherwayofvalidatingXMLdocuments:usingXMLschemas.
TheXMLSchemalanguageisalsoreferredtoasXMLSchemaDefinition(XSD),
describesthestructureofanXMLdocument.
Definesthelegalbuildingblocks(elementsandattributes)ofanXMLdocumentlike
DTD.
defineswhichelementsarechildelements
definesthenumberandorderofchildelements
defineswhetheranelementisemptyorcanincludetext
definesdatatypesforelementsandattributes
definesdefaultandfixedvaluesforelementsandattributes
XMLSchemaswillbeusedinmostWebapplicationsasareplacementforDTDs.Herearesome
reasons:
XMLSchemasareextensibletofutureadditions
XMLSchemasarericherandmorepowerfulthanDTDs
XMLSchemasarewritteninXML
XMLSchemassupportdatatypesandnamespaces
CreatingXMLSchemasbyUsingXMLSchema-CreationTools
HiTSoftware

IntegrativeProgramming
Page29
xmlArchitect
XMLspy
XMLRay
MicrosoftVisualStudio.NET
XSDSimpleElement
Thesyntaxfordefiningasimpleelement
DefaultandFixedValuesforSimpleElements
XSDAttributes
Thesyntaxfordefininganattribute
DefaultandFixedValuesforAttributes
OptionalandRequiredAttributes
XSDComplexElements
HowtoDefineaComplexElementusingXMLScheme
XSDEmptyElements
XSDIndicators
Orderindicatorsare:
All
Choice
Sequence
XSDSimpleElement
AsimpleelementisanXMLelementthatcancontainonlytext.
Itcannotcontainanyotherelementsorattributes.
XMLSchemahasalotofbuilt-indatatypes.Themostcommontypesare:
1.xs:string
2.xs:decimal
3.xs:integer
4.xs:boolean
5.xs:date
6.xs:time
Thesyntaxfordefiningasimpleelementis:
<xs:elementname="xxx"type="yyy"/>
Example
<lastname>Refsnes</lastname>

IntegrativeProgramming
Page30
<age>36</age>
<dateborn>1970-03-27</dateborn>
<xs:elementname="lastname"type="xs:string"/>
<xs:elementname="age"type="xs:integer"/>
<xs:elementname="dateborn"type="xs:date"/>
DefaultandFixedValuesforSimpleElements
Simpleelementsmayhaveadefaultvalueorafixedvaluespecified.
1.Adefaultvalueisautomaticallyassignedtotheelementwhennoothervalueis
specified.
<xs:elementname="color"type="xs:string"default="red"/>
2.Afixedvalueisalsoautomaticallyassignedtotheelement,andyoucannot
specifyanothervalue.
<xs:elementname="color"type="xs:string"fixed="red"/>
XSDAttributes
Simpleelementscannothaveattributes.
Ifanelementhasattributes,itisconsideredtobeofacomplextype.Buttheattribute
itselfisalwaysdeclaredasasimpletype.
Thesyntaxfordefininganattributeis:
<xs:attributename="xxx"type="yyy"/>
Example
<lastnamelang="EN">Smith</lastname>
<xs:attributename="lang"type="xs:string"/>
DefaultandFixedValuesforAttributes
Attributesmayhaveadefaultvalueorafixedvaluespecified.
<xs:attributename="lang"type="xs:string"default="EN"/>
<xs:attributename="lang"type="xs:string"fixed="EN"/>
OptionalandRequiredAttributes
Attributesareoptionalbydefault.Tospecifythattheattributeisrequired,usethe"use"
attribute:
<xs:attributename="lang"type="xs:string"use="required"/>
XSDComplexElements

IntegrativeProgramming
Page31
AcomplexelementisanXMLelementthatcontainsotherelementsand/orattributes.
Therearefourkindsofcomplexelements:
Example:
1.AcomplexXMLelement,"product",whichisempty:<productpid="1345"/>
2.AcomplexXMLelement,"employee",whichcontainsonlyotherelements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
3.AcomplexXMLelement,"food",whichcontainsonlytext:
<foodtype="dessert">Icecream</food>
4.AcomplexXMLelement,"description",whichcontainsbothelementsandtext:
<description>
Ithappenedon<datelang=“EN">03.03.99</date>
</description>
HowtoDefineaComplexElementusingXMLScheme
ComplexXMLelement,"employee",whichcontainsonlyotherelements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
The"employee"elementcanbedeclareddirectlybynamingtheelement:
<xs:elementname="employee">
<xs:complexType>
<xs:sequence>
<xs:elementname="firstname"type="xs:string"/>
<xs:elementname="lastname"type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Anemptycomplexelementcannothavecontents,onlyattributes.

IntegrativeProgramming
Page32
<productprodid="1345"/>
Itispossibletodeclarethe"product"elementmorecompactly:
<xs:elementname="product">
<xs:complexType>
<xs:attributename="prodid"type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
XSDIndicators
Howelementsaretobeusedindocumentswithindicators.
Orderindicatorsareusedtodefinetheorderoftheelements.Theyare:
1.All
2.Choice
3.Sequence
AllIndicator:
The<all>indicatorspecifiesthatthechildelementscanappearinanyorder,andthat
eachchildelementmustoccuronlyonce:
<xs:elementname="person">
<xs:complexType>
<xs:all>
<xs:elementname="firstname"type="xs:string"/>
<xs:elementname="lastname"type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
ChoiceIndicator:
The<choice>indicatorspecifiesthateitheronechildelementoranothercanoccur:
<xs:elementname="person">
<xs:complexType>
<xs:choice>
<xs:elementname="employee"type="employee"/>
<xs:elementname="member"type="member"/>

IntegrativeProgramming
Page33
</xs:choice>
</xs:complexType>
</xs:element>
SequenceIndicator:
The<sequence>indicatorspecifiesthatthechildelementsmustappearinaspecificorder:
<xs:elementname="person">
<xs:complexType>
<xs:sequence>
<xs:elementname="firstname"type="xs:string"/>
<xs:elementname="lastname"type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
XMLExample(“note.xml”)
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don'tforgetmethisweekend!</body>
</note>
XSDExample(“note.xsd”)
<xs:elementname="note">
<xs:complexType>
<xs:sequence>
<xs:elementname="to"type="xs:string"/>
<xs:elementname="from"type="xs:string"/>
<xs:elementname="heading"type="xs:string"/>
<xs:elementname="body"type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

IntegrativeProgramming
Page34
Example(shiporder.xml):
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<shiporderorderid="889923">
<orderperson>JohnSmith</orderperson>
<shipto>
<name>OlaNordmann</name>
<address>Langgt23</address>
<city>4000Stavanger</city>
<country>Norway</country>
</shipto>
</shiporder>
Example"shiporder.xsd":
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:elementname="shiporder">
<xs:complexType>
<xs:sequence>
<xs:elementname="orderperson"type="xs:string"/>
<xs:elementname="shipto">
<xs:complexType>
<xs:sequence>
<xs:elementname="name"type="xs:string"/>
<xs:elementname="address"type="xs:string"/>
<xs:elementname="city"type="xs:string"/>
<xs:elementname="country"type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attributename="orderid"type="xs:string"use="required"/>
</xs:complexType>

IntegrativeProgramming
Page35
</xs:element>
</xs:schema>
XMLParser(ParsingXMLdocuments)
Allmodernbrowsershaveabuilt-inXMLparser.
AnXMLparserconvertsanXMLdocumentintoanXMLDOMobjectwhichcan
thenbemanipulatedwithJavaScript.
ParseanXMLDocument
ThefollowingcodefragmentparsesanXMLdocumentintoanXMLDOMobject:if
(window.XMLHttpRequest)
{//codeforIE7+,Firefox,Chrome,Opera,Safarixmlhttp=newXMLHttpRequest();
}
else
{//codeforIE6,IE5
xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","books.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
XMLDOM
TheXMLDOMdefinesastandardwayforaccessingandmanipulatingXMLdocuments.
TheXMLDOMviewsanXMLdocumentasatree-structure.
AllelementscanbeaccessedthroughtheDOMtree.
Theircontent(textandattributes)canbemodifiedordeleted,andnewelementscanbe
created.
Theelements,theirtext,andtheirattributesareallknownasnodes.
TheHTMLDOM
TheHTMLDOMdefinesastandardwayforaccessingandmanipulatingHTML
documents.
AllHTMLelementscanbeaccessedthroughtheHTMLDOM.

IntegrativeProgramming
Page36
LoadanXMLFile-Cross-browser
parsesanXMLdocument("note.xml")intoanXMLDOMobjectandthenextractssome
informationfromitwithaJavaScript:
Example
<html>
<body>
<spanid="to"></span>
<spanid="from"></span>
<spanid="message"></span>
<script>
if(window.XMLHttpRequest)
{
//codeforIE7+,Firefox,Chrome,Opera,Safarixmlhttp=newXMLHttpRequest();
}
else
{
//codeforIE6,IE5
xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
</script>
</body>

IntegrativeProgramming
Page37
</html>