Building web serivices with Java making sencse of XML

Building Web Services with Java™: Making Sense of XML, SOAP, WSDL, and UDDI

  By Steve Graham , Simeon Simeonov , Toufic Boubez , Doug Davis , Glen Daniels , Yuichi Nakamura , Ryo Neyama Publisher : Sams Publishing Pub Date : December 12, 2001

  ISBN : 0-672-32181-5 Pages : 600 : Slots

  Based on open indust ry st andards, Web services enable your soft w are t o int egrat e w it h part ners and client s in a fashion t hat is loosely coupled, sim ple, and plat form - independent . Building Web Services w it h Java: Making Sense of XML, SOAP, WSDL, and UDDI present s t he concept of Web services and explains how t o incorporat e Web services int o your business. The book addresses em erging st andards associat ed wit h Web services, such as Sim ple Obj ect Access Prot ocol ( SOAP) , Web Services Descript ion Language ( WSDL) , and Universal Descript ion Discovery and I nt egrat ion ( UDDI ) .

  Copyright Copyright © 2002 by Sams Publishing

  All right s reserved. No part of t his book shall be reproduced, st ored in a ret rieval syst em , or t ransm it t ed by any m eans, elect ronic, m echanical, phot ocopying, recording, or ot herw ise, w it hout w rit t en perm ission from t he publisher. No pat ent liabilit y is assum ed w it h respect t o t he use of t he inform at ion cont ained herein. Alt hough every precaut ion has been t aken in t he preparat ion of t his book, t he publisher and aut hor assum e no responsibilit y for errors or om issions. Nor is any liabilit y assum ed for dam ages result ing from t he use of t he inform at ion cont ained herein. Library of Congress Cat alog Card Num ber: 2001090920 Print ed in t he Unit ed St at es of Am erica First Print ing: Decem ber 2001 04 03 02 01 4 3 2 1

  Trademarks

  All t erm s m ent ioned in t his book t hat are know n t o be t radem arks or service m arks have been appropriat ely capit alized. Sam s Publishing cannot at t est t o t he accuracy of t his inform at ion. Use of a t erm in t his book should not be regarded as affect ing t he validit y of any t radem ark or service m ark.

  Warning and Disclaimer

  Every effort has been m ade t o m ake t his book as com plet e and as accurat e as possible, but no w arrant y or fit ness is im plied. The inform at ion provided is on an " as is" basis. The aut hors and t he publisher shall have neit her liabilit y nor responsibilit y t o any person or ent it y w it h respect t o any loss or dam ages arising from t he inform at ion cont ained in t his book.

  Executive Editor Michael Stephens Acquisitions Editor Michael Stephens Development Editor Tiffany Taylor Managing Editor Matt Purcell Project Editor Christina Smith Copy Editor Tiffany Taylor Indexer

  Eric Schroeder Proofreader Plan-It Publishing Technical Editor Chad Fowler Craig Pfiefer Team Coordinator Pamalee Nelson Media Developer Dan Scherf Interior Designer Anne Jones Cover Designer Aren Howell Page Layout Heather Stephenson

About the Authors

  St eve Graham is an archit ect in t he Em erging Technologies division of I BM Soft w are Group. He has spent t he last several years working on service- orient ed archit ect ures, m ost recent ly as part of t he I BM Web Services I nit iat ive. Prior t o t his, St eve w orked as a t echnologist and consult ant on various em erging t echnologies such as Java and XML, and before t hat he w as an archit ect and consult ant w it h t he I BM Sm allt alk consult ing organizat ion.

  Before j oining I BM, St eve w as a developer w it h Sybase, a consult ant , and a facult y m em ber in t he Depart m ent of Com put er Science at t he Universit y of Wat erloo. St eve holds a BMat h and MMAt h in com put er science from t he Universit y of Wat erloo. You can reach him at sggraham @us.ibm .com .

  Sim eon ( Sim ) Sim eonov has been developing soft ware for m ore t han 15 years. Sim 's areas of expert ise encom pass obj ect - orient ed t echnology, com piler t heory, I nt ernet t ools, ent erprise com put ing, and t he broad spect rum of XML t echnologies. As chief archit ect at Macrom edia I nc., Sim provides direct ion for t he evolut ion of t he com pany's t echnology and product st rat egy as w ell as t he archit ect ure of it s server- side plat form product s. Previously, Sim w as chief archit ect at Allaire Corporat ion, w here his init iat ives brought about num erous innovat ions t o t he core product lines. Sim is current ly w orking on service- orient ed archit ect ures for t he next generat ion of

  Process in t he areas of I nt ernet applicat ions, XML, and Web Services. Sim also represent s Macrom edia on t he W3C w orking group on XML Prot ocol. He is a regular speaker at conferences and a m ont hly colum nist for XML Journal. Sim holds a B.A. in Com put er Science, Econom ics, and Mat hem at ics and a MSc in Com put er Science.

  Toufic Boubez is t he chief t echnology officer of Saffron Technology. Prior t o j oining Saffron, he w as a senior t echnologist in I BM's Em erging Technologies group, and lead archit ect of I BM's Web services init iat ive. He w as I BM's t echnical represent at ive t o t he UDDI Web Services Consort ium w it h Microsoft and Ariba and co- aut hored t he UDDI API specificat ion. He w as also t he I BM t echnical lead on t he UN/ CEFACT/ OASI S ebXML init iat ive and helped drive I BM's early XML and Web services st rat egies.

  Dr. Boubez has m ore t han 15 years of experience in I T and has published and present ed on Web services, XML, obj ect t echnology, dist ribut ed com put ing, int elligent agent s, B2B, business m odeling, sim ulat ion, neural net w orks, and w avelet analysis. He holds a doct orat e in Biom edical Engineering from Rut gers Universit y.

  Doug Davis w orks in t he Em erging Technology organizat ion of I BM, w orking on I BM's Web Services Toolkit , and he is one of I BM's represent at ives in t he W3C XML Prot ocol w orking group. Previous proj ect s include WebSphere's Machine Translat ion proj ect , Team Connect ion, and I BM's FORTRAN 90 com piler. Doug has a Bachelor of Science degree from t he Universit y of California at Davis and a Mast er's degree in Com put er Science from Michigan St at e Universit y.

  Glen Daniels, in his 13 years in t he soft ware indust ry, has run t he gam ut from device drivers and net w ork st acks up t hrough user int erface and Web sit e w ork, in everyt hing from assem bly language t o C+ + t o Lisp. Dist ribut ed com put ing has alw ays been a passion, and as such he is current ly t echnical lead for t he JRun Web Services t eam at Macrom edia. Glen is an act ive m em ber of t he W3C XML Prot ocol group as w ell as one of t he lead developers of Axis. When not coding, he can oft en be found playing bass or harm onica, hanging out w it h his m any crazy friends in t he Bost on area, or relaxing w it h his cat s.

  Yuichi Nakam ura is an advisory researcher at t he I BM Tokyo Research Laborat ory. His research int erest s are Web services including SOAP and XML securit y, obj ect - orient ed syst em s, J2EE, m ult iagent syst em s, B2B e- com m erce, and knowledge engineering. He received an MSc and a PhD in Applied Physics from Osaka Universit y in 1987 and 1990, respect ively. Ryo Neyam a is a researcher at t he I BM Tokyo Research Laborat ory. His research int erest s are dist ribut ed obj ect syst em s including Web services, obj ect request brokers, and securit y. He received an MSc in I nform at ion and Com put er Science from Waseda Universit y in 1999.

Acknowledgments

  To Karen, Erin and Jessie, m y fam ily, m y inspirat ion. For all t he m om ent s sacrificed t o creat e t his book, m y m ost heart felt t hanks for your underst anding. My t hanks t o m y cow orkers at I BM, and in part icular t he WSTK t eam for doing such an out st anding j ob. My t hanks also t o Rod Sm it h for fost ering an excellent environm ent for creat ive work. My t hanks also t o t he st aff at Sam s, part icularly Tiffany Taylor and Michael St ephens, for t he hard w ork t hat w ent int o m aking t his proj ect a realit y. Rom ans 12: 2.

  I t is m uch easier t o w rit e a book w hen ot hers believe you can. My deepest t hanks t o Pyrra: m y t rue love and a const ant source of inspirat ion. Thanks also t o all m y friends and co- w orkers w ho never st opped being int erest ed in Web services and t he progress of t he book. See? I t 's done.

  —Sim Sim eonov To Lucy and Yasm ine: Thank you for your pat ience, love, and underst anding. This was a m aj or undert aking for a new dad w it h anot her full- t im e j ob. To m y old I BM t eam , Sam Adam s, St eve Burbeck, Jay Casler, St eve Graham , Maryann Hondo, and Rod Sm it h, t hank you for t he great , challenging, and recept ive w ork environm ent . I seriously don't t hink t he concept of Web services w ould have evolved t o w here it is t oday in a different environm ent . To m y new t eam at Saffron, t hank you for replicat ing t hat environm ent ! —Toufic Boubez Lin—I ow e so m any t hings t o your pat ience, support , and m ost of all your sense of hum or. I can never say it enough, but t hank you.

  —Doug Davis For all m y friends and fam ily w ho so pat ient ly cont inue t o be t here for m e t hrough even t he busiest t im es—love and t hanks t o all of you.

  —Glen Daniels To Michiyo: Thank you for your underst anding and pat ience during t his w ork. Thanks t o m y kids, Arisa and Ryot aro: You alw ays m ade m e happy w it h your lovely sm iles.

  My t hanks t o all XML and Securit y t eam m em bers at I BM Tokyo Research Laborat ory. —Yuichi Nakam ura My t hanks t o m y parent s, Jun and Sachie, for bringing m e up and alw ays support ing m e.

  My t hanks also t o Takako and m y friends for t heir encouragem ent and underst anding. My t hanks t o m y cow orkers at I BM Tokyo Research Laborat ory for t heir deep insight s on Web services and relat ed t echnologies.

  —Ryo Neyam a

Tell Us What You Think!

  As t he reader of t his book, you are our m ost im port ant crit ic and com m ent at or. We value your opinion and w ant t o know w hat w e're doing right , w hat w e could do bet t er, w hat areas you'd like t o see us publish in, and any ot her w ords of w isdom you're w illing t o pass our way.

  As an Execut ive Edit or for Sam s Publishing, I w elcom e your com m ent s. You can fax, e- m ail, or w rit e m e direct ly t o let m e know w hat you did or didn't like about t his book—as w ell as w hat w e can do t o m ake our books st ronger. Please not e t hat I cannot help you w it h t echnical problem s relat ed t o t he t opic of t his book, and t hat due t o t he high volum e of m ail I receive, I m ight not be able t o reply t o every m essage. When you w rit e, please be sure t o include t his book's t it le and aut hors' nam es as w ell as your nam e and phone or fax num ber. I w ill carefully review your com m ent s and share t hem w it h t he aut hors and edit ors w ho w orked on t he book.

  E-mail: feedback@samspublishing.com Mail:

  Michael St ephens Execut ive Edit or Sam s Publishing 201 West 103rd St reet I ndianapolis, I N 46290 USA

  Introduction

  Welcom e t o t he w orld of Web services! This is a rapidly evolving set of st andards and im plem ent at ion t echnologies t hat have great prom ise for t he w orld of applicat ion int egrat ion and dist ribut ed com put ing. Before w e get going, w e need t o clarify som e t hings about t he purpose and st ruct ure of t he book. Let 's t alk about t hem now .

Goals of this Book

  The overall goal of t his book is t o fam iliarize you w it h t he concept of Web services and w hat it w ill t ake t o incorporat e Web services as part of your business. We w ill int roduce t he concept of Web services and give you a fram ew ork t hat describes how you can posit ion t he various em erging st andards t hat are associat ed w it h Web services, such as Sim ple Obj ect Access Prot ocol ( SOAP) , Web Services Descript ion Language ( WSDL) , and Universal Descript ion Discovery and I nt egrat ion ( UDDI ) . We w ill help posit ion Web services from a business and t echnical perspect ive, explaining and dem onst rat ing how Web services can be used t o address various business problem s,

  part icularly relat ed t o applicat ion int egrat ion. Anot her goal of t his book is t o help developers underst and t he issues and det ails relat ed t o building Web services using t he t echniques covered by t his book. What pieces are required w hen you're planning a Web services st rat egy? What t hings do you need t o t ake care of w hen developing Web services? We provide lot s of exam ples and running code t o dem onst rat e t hese approaches. We also review in det ail t he Apache Axis Web services infrast ruct ure w it h our running exam ples. Ot her t ools and Web services infrast ruct ures are discussed as w ell, but not in t he sam e det ail as Axis.

Assumed Background

  This book is m eant for com put ing t echnical professionals w it h som e experience building Web applicat ions and dist ribut ed com put ing syst em s. You don't need t o be a seasoned vet eran of t he dist ribut ed obj ect w ars t o appreciat e t his book, but som e fam iliarit y w it h Web- based archit ect ures and t echniques such as HTTP and HTML is assum ed. I f you do not have any experience w it h t hese t echniques, som e of t he m at erial could be a lit t le confusing—part icularly som e of t he code exam ples—but you should st ill be able t o get a lot out of t his book.

  We assum e you are fam iliar w it h Java, and in part icular t he Java Server Pages ( JSP) and Java servlet t echnologies. We also briefly discuss t he relat ionship bet w een Ent erprise Java Beans ( EJBs) and Web services, so som e fam iliarit y w it h EJBs is helpful as w ell. I f you need t o supplem ent your underst anding of t hese t echniques, m any, m any good

  You w ill also discover t hat t he Ext ensible Markup Language ( XML) is at t he core of all t hings dealing w it h Web service. Alt hough w e devot e an ent ire chapt er t o explaining t he core pieces of XML needed t o build Web services, t he m ore underst anding of XML you have, t he m ore successful you w ill be in building Web services.

  Philosophy

  I t is difficult t o st ruct ure a book on Web services. The concept s and st andards are very m uch int erdependent . I t is hard t o cover each t opic in isolat ion, because it is t he com binat ion of t hese concept s and st andards t hat m ake Web services im port ant t o dist ribut ed com put ing.

  The philosophy of t his book can be sum m arized by four point s: pragm at ics, progressive disclosure, a running exam ple, and a service- orient ed archit ect ure fram ew ork.

Pragmatics

  I n t his book, w e t ry t o get t o program m ing exam ples and running code as quickly as possible. I n part icular, w e focus on building and consum ing SOAP- based Web services using t he Apache Axis Web services infrast ruct ure. This is a Java- cent ric approach t o building Web services. Whereas w e em phasize t hat Web services are fundam ent ally program m ing language neut ral, ult im at ely, any given Web service is im plem ent ed in som e program m ing language t echnology. I n t he case of t his book, w e have chosen Java. Where issues of int eroperabilit y w it h Web services w rit t en in ot her program m ing languages m ight appear, w e not e t hem . Det ailed coverage of ot her Web services im plem ent at ion approaches, such as Microsoft 's .NET, is beyond t he scope of t his book, alt hough w e do give som e basic exam ples of .NET and ot her environm ent s in Chapt er 8 , " I nt eroperabilit y, Tools, and Middlew are Product s."

  Progressive Disclosure

  Aft er t he overview of Web services, w e st art w it h t he fundam ent als of XML, and t hen layer on new concept s, m ot ivat ed by a business com put ing problem . These layers produce a series of Web services t echnology " st acks." For each of t he t echnologies and st andards in t he Web services arena, w e focus on underst anding t he t echnology from t he perspect ive of w hat problem s it solves, balancing t he explanat ion of t he t echnology it self.

  Running Example

  The t echnologies and st andards t hat m ake up t he Web services concept are each exam ined in t he cont ext of a running exam ple ( w hich w e discuss lat er in t his int roduct ion) . The use of t he running exam ple adds insight t o t he explanat ion of t he concept in t he t ext of t he book and support s t he progressive disclosure approach as w e follow t he exam ple, adding t he layers of Web services t echnology t o t he solut ion. This approach helps posit ion various best - pract ices approaches t o Web service developm ent and deploym ent . You can dow nload t he source code for t hese running exam ples from

  w w w .sam spublishing.com . When you reach t hat page, ent er t his book's I SBN num ber

  ( 0672321815) in t he search box t o access inform at ion about t he book and a Source Code link.

Service-Oriented Architecture

  The exam ples and Web services concept s are discussed in t he cont ext of a service- orient ed archit ect ure ( SOA) t hat w e int roduce in Chapt er 1 , " Web Services Overview ." We use t he SOA fram ew ork t o help posit ion t he various Web services concept s back int o a bigger pict ure.

  

Chapt er 1 begins t he book w it h an explanat ion of w hat t he Web services approach is all

  about . We describe w hat a Web service is, w hat st andards and t echnologies are associat ed w it h Web services, and w hat problem s can be solved using Web services. We use t his chapt er t o int roduce t he SOA concept ual fram ew ork and begin t o explain how t he various Web services st andards such as SOAP, WSDL, and UDDI fit t oget her. This chapt er w ill give you a solid concept ual basis for t he rest of t he book. Before w e can get int o t he core Web services st andards, w e t ake a brief side t rip t o explain XML in Chapt er 2 , " XML Prim er." Because XML is at t he heart of all t he Web services st andards and t echniques, it is im port ant you underst and it w ell. XML is a huge t opic, but w e focus our exam inat ion of XML on w hat you w ill need t o know in order t o underst and t he rest of t he Web services t opics. Aft er t he review of XML, Chapt er 3 , " Sim ple Obj ect Access Prot ocol ( SOAP) ," dives in t o t he core problem of invoking a Web service. We review t he t opic of XML m essaging in a dist ribut ed com put ing environm ent , focusing on t he SOAP m essage enveloping st andard. SOAP form s t he core basis of com m unicat ion bet w een a service request or and a service provider in a Web services environm ent .

  

Chapt er 4 , " Creat ing Web Services," refines your underst anding of SOAP in t he cont ext of

  a part icular SOAP infrast ruct ure: t he Apache Axis proj ect . Chapt er 4 dives int o t he det ails of how Axis w orks and how you can use it t o m ake it easy t o deploy Web services and have your applicat ions consum e Web services. At t his point , you w ill have a great background underst anding of SOAP and at least one w ay t o m ake SOAP real: Axis. But SOAP alone is not enough t o do m ore t han very sim ple Web services. Chapt er 5 , " Using SOAP for e- Business," adds det ail t o t he concept s int roduced in Chapt ers 3 and

  4 by explaining how you can build Web services for

  com plet e business com put ing problem s. Chapt er 5 discusses how Web services addresses m any dist ribut ed com put ing problem s including securit y, perform ance, qualit y of service, reliabilit y, and so on.

  Chapt er 6 , " Describing Web Services," int roduces t he im port ant not ion of service

  descript ion, w hich is key t o m aking Web services t he great applicat ion int egrat ion t echnology for building loosely coupled syst em s. Chapt er 6 discusses how Web services uses service descript ion t o address t he problem of com m unicat ing w hat det ails t he service request or needs t o know about t he Web service in order t o properly underst and how ( and why) t o invoke it . Now , you need t o underst and how t he service request or got t he service descript ion in t he first place. Chapt er 7 , " Discovering Web Services," picks up where Chapt er 6 left off, discussing t he various t echniques for Web service discovery. This chapt er exam ines t he st andards relat ed t o finding w hat Web services are provided by businesses w it h w hich a com pany m ight w ant t o collaborat e.

  Chapt er 8 , " I nt eroperabilit y, Tools, and Middlew are Product s," fills out your

  underst anding of best pract ices in t he Web services arena by exam ining various ot her Web services infrast ruct ure and t ooling environm ent s. The book concludes w it h a forw ard- looking Chapt er 9 , " Fut ure Concept s," w hich speculat es on som e possible fut ure uses of Web services t echnologies t o address ot her problem s in dist ribut ed com put ing.

Note

  This book int roduces quit e a few t erm s w it h w hich you m ight not be fam iliar. We have included a glossary at t he back of t his book t hat act s as a great reference guide t o t he t erm inology used in t he book. We w ill annot at e t he first use of each t erm appearing in

  So, before w e get st art ed, let 's int roduce t he fict ional com pany w e'll use for our exam ples t hroughout t his book: Skat esTow n. We w ill follow Skat esTow n as t he com pany exploit s Web services t o im prove it s business.

Introducing SkatesTown

  Skat esTow n is a sm all but grow ing business in New York founded by t hree m echanically inclined friends w it h a passion for cars and skat eboards. They st art ed by designing and selling cust om pre- built boards out of Dean Carroll's garage, and w ord soon spread about t he qualit y of t heir w ork. They cam e up w it h som e innovat ive new const ruct ion t echniques, and w it hin m ont hs t hey had orders piling up. Now Skat esTow n has a sm all m anufact uring operat ion in Brooklyn, and t he com pany is selling boards, clot hing, and equipm ent t o st ores around t he cit y. Dean, Frank St em kow ski, and Chad Washingt on couldn't be happier about how t heir business has grow n.

  Of t he t hree, Chad is t he real gearhead, and he has been responsible for m ost of t he daring const ruct ion and design choices t hat have helped Skat esTow n get w here it is t oday. He's t he president and head of t he t eam . Frank, gregarious and a sm oot h t alker ever since childhood, now handles m arket ing and sales. Dean has t ight ly t racked t he com put er revolut ion over t he years, and is chief t echnical officer for t he com pany. A few years back, Dean realized t hat net w orking t echnology w as going t o be big, and he w ant ed t o m ake sure t hat Skat esTow n could cat ch t he w ave and ut ilize dist ribut ed com put ing t o leverage it s business. This focus t urned out t o be a great m ove. Dean set up a Web presence so Skat esTow n could help it s cust om ers st ay up- t o- dat e w it hout requiring a large st aff t o answ er phones and quest ions. He also built an online order- processing syst em t o help st ream line t he act ual flow of t he business w it h net w ork- enabled client s. I n recent m ont hs, m ore and m ore st ores w ho carry Skat esTow n product s have been using t he syst em t o great effect .

Our Story Begins…

  At present , Dean is pret t y happy w it h t he w ay t hings are w orking w it h Skat esTow n's elect ronic com m erce syst em s. But t here have been a few problem s, and Dean is sure t hat t hings could be even bet t er. He realizes t hat as t he business grow s, t he m anual t asks associat ed w it h order gat hering and invent ory resupply w ill lim it t he com pany's success. Alw ays one t o w at ch t he horizon, Dean has heard t he buzz about Web services, and w ant s t o know m ore. At t he urging of a friend, he got in t ouch w it h Al Rosen, a cont ract or for Silver Bullet Consult ing. Silver Bullet specializes in Web services solut ions, and aft er a couple of m eet ings w it h Al, Dean w as convinced—he hired SBC t o com e in, evaluat e Skat esTow n's syst em s, and help t he com pany grow int o a Web service–enabled business.

  As w e m ove t hrough t he rest of t he book, w e'll keep an eye on how Skat esTow n uses t echnologies like XML and, lat er, SOAP, WSDL, and UDDI t o increase efficiency, product ivit y, and est ablish new and valuable relat ionships w it h it s cust om ers and business part ners. Silver Bullet , as w e'll see, usually lives up t o it s nam e.

  Trends in e-business • Why Do We Need a Web Services Approach? • Service-Oriented Architectures • Web Services Interoperability Stacks

  • I n t his chapt er, w e w ill provide t he basic t erm inology and set of concept s t hat put t he rem ainder of t he book int o cont ext . We w ill define w hat w e m ean by a Web service and describe sit uat ions in w hich Web services w ill play an im port ant role. We w ill describe a sim ple fram ew ork, called service- orient ed archit ect ure , t hat helps st ruct ure t he applicat ion of Web services t echnologies. We w ill also provide a fram ew ork, in t he form of t hree " int eroperabilit y" st acks t hat posit ion how t he various Web services t echnologies such as Sim ple Obj ect Access Prot ocol ( SOAP) , Web Services Descript ion Language ( WSDL) , and Universal Descript ion Discovery and I nt egrat ion ( UDDI ) relat e. The rest of t he book, t hen, is an elaborat ion of t he basic concept s present ed here.

What Is a Web Service?

  This is a book about building Web services. We cannot describe how t o build a Web service w it hout first clarifying w hat w e m ean by a Web service. The t erm Web services has gained a lot of m om ent um in t he last year. Many soft w are vendors ( large and sm all) are announcing Web services init iat ives and adopt ion ( see t he sidebar " Web Services Market Dynam ics " ) . Many organizat ions are involved in t he refinem ent of Web services st andards. Alt hough t here seem s t o be a slow convergence t ow ards a com m on underst anding of w hat t he t erm m eans, t here is no single, universally adopt ed definit ion of w hat is m eant by t he t erm Web service. This sit uat ion is rem iniscent of t he early days of obj ect - orient ed program m ing: Not unt il t he concept s of inherit ance, encapsulat ion, and polym orphism w ere w ell defined did obj ect - orient ed program m ing becom e accept ed int o t he m ainst ream of developm ent m et hodologies. Several m aj or Web services infrast ruct ure providers have published t heir definit ions for a Web service:

  I BM offers t his definit ion at

  ht t p: / / w w w 4.ibm .com / soft w are/ solut ions/ Webservices/ pdf/ WSCA.pdf :

  A Web service is an int erface t hat describes a collect ion of operat ions t hat are net w ork accessible t hrough st andardized XML m essaging. Web services fulfill a specific t ask or a set of t asks. A Web service is described using a st andard, form al XML not ion, called it s service descript ion, t hat provides all of t he det ails necessary t o int eract w it h t he service, including m essage form at s ( t hat det ail t he operat ions) , t ransport prot ocols, and locat ion.

  The nat ure of t he int erface hides t he im plem ent at ion det ails of t he service so t hat it can be used independent ly of t he hardw are or soft w are plat form on w hich it is im plem ent ed and independent ly of t he program m ing language in w hich it is w rit t en. This allow s and encourages Web services t echnology im plem ent at ions. Web services can be used alone or in conj unct ion w it h ot her Web services t o carry out a com plex aggregat ion or a business t ransact ion. Microsoft has a couple of definit ions for Web service. The first is at ht t p: / /

  m sdn.m icrosoft .com / library/ default .asp?url= / nhp/ Default .asp?cont ent id= 28000442 :

  A Web service is a unit of applicat ion logic providing dat a and services t o ot her applicat ions. Applicat ions access Web services via ubiquit ous Web prot ocols and dat a form at s such as HTTP, XML, and SOAP, w it h no need t o w orry about how each Web service is im plem ent ed. Web services com bine t he best aspect s of com ponent - based developm ent and t he Web, and are a cornerst one of t he Microsoft .NET program m ing m odel.

  The ot her Microsoft definit ion is at

  ht t p: / / m sdn.m icrosoft .com / library/ default .asp?url= / library/ en- us/ dnWebsrv/ ht m l/ Websvcs_plat form .asp :

  A Web service is program m able applicat ion logic accessible using st andard I nt ernet prot ocols. Web services com bine t he best aspect s of com ponent - based developm ent and t he Web. Like com ponent s, Web services represent black- box funct ionalit y t hat can be reused w it hout w orrying about how t he service is im plem ent ed. Unlike current com ponent t echnologies, Web services are not accessed via obj ect - m odel- specific prot ocols, such as t he dist ribut ed Com ponent Obj ect Model ( DCOM) , Rem ot e Met hod I nvocat ion ( RMI ) , or I nt ernet I nt er- ORB Prot ocol ( I I OP) . I nst ead, Web services are accessed via ubiquit ous Web prot ocols and dat a form at s, such as Hypert ext Transfer Prot ocol ( HTTP) and Ext ensible Markup Language ( XML) . Furt herm ore, a Web service int erface is defined st rict ly in t erm s of t he m essages t he Web service accept s and generat es.

  Consum ers of t he Web service can be im plem ent ed on any plat form in any program m ing language, as long as t hey can creat e and consum e t he m essages defined for t he Web service int erface. Sun provides t he follow ing definit ion at

  ht t p: / / w w w .sun.com / soft w are/ sunone/ faq.ht m l# 2 :

  Web services are soft ware com ponent s t hat can be spont aneously discovered, com bined, and recom bined t o provide a solut ion t o t he user's problem / request . The Java™ language and XML are t he prom inent t echnologies for Web services.

  As you can see, t here is broad agreem ent on w hat a Web service m ight be, but no single agreed- upon definit ion. Many developers w ill claim t hey cannot define w hat a Web service is, but t hey know one w hen t hey see one. From t he perspect ive of t his book, a Web service is a plat form and im plem ent at ion independent soft w are com ponent t hat can be:

  Described using a service description language • Published to a registry of services • Discovered through a standard mechanism (at runtime or design time) • Invoked through a declared API, usually over a network

  • Composed with other services •
One im port ant point is t hat a Web service need not necessarily exist on t he World Wide Web. This is an unfort unat e hist orical nam ing issue. A Web service can live anyw here on t he net w ork, I nt er- or int ranet ; som e Web services can be invoked by a sim ple m et hod invocat ion in t he sam e operat ing syst em process, or perhaps using shared m em ory bet w een t ight ly coupled processes running on t he sam e m achine. I n fact , Web services have lit t le t o do w it h t he brow ser- cent ric, HTML- focused World Wide Web. Som et im es, t he nam es w e choose in t he inform at ion t echnology ( I T) indust ry don't m ake a lot of sense; t hey sim ply t ake on a life of t heir ow n.

  Anot her im port ant point is t hat a Web service's im plem ent at ion and deploym ent plat form det ails are not relevant t o a program t hat is invoking t he service. A Web service is available t hrough it s declared API and invocat ion m echanism ( net w ork prot ocol, dat a encoding schem es, and so on) . This is analogous t o t he relat ionship bet w een a Web brow ser and a Web applicat ion server: Very lit t le shared underst anding exist s bet w een t he t w o com ponent s. The Web brow ser doesn't part icularly care if t he Web applicat ion server is Apache Tom cat , Microsoft I I S, or I BM Websphere. The shared underst anding is t hat t hey bot h speak HTTP and converse in HTML or a very lim it ed set of MI ME t ypes. Sim ilarly, t he Web applicat ion server really doesn't care w hat kind of client is using it — various brands of Web browsers or even non- browser client s. This m inim al shared underst anding bet w een com ponent s allow s Web services t o form a syst em of loosely coupled com ponent s.

Business Perspective

  To a business person, t he Web services approach is all about int egrat ion: int egrat ing applicat ion funct ionalit y w it hin an organizat ion or int egrat ing applicat ions bet w een business part ners ( in a supply chain, for exam ple) . The scenario in t his book illust rat es t his approach, part icularly in Chapt er 7 , " Discovering Web Services." This applicat ion int egrat ion allow s t im e and cost efficiencies for receiving purchase orders, answ ering st at us inquiries, processing shipm ent request s, and so on. The im port ant point is t hat applicat ion int egrat ion is enabled w it hout t ight lock- in t o any part icular business part ner. I f anot her supplier has a bet t er price, shipping t erm s, or qualit y assurance, t hen a com pany's reorder syst em s can be easily reposit ioned t o use t hat supplier; doing so is as easy as point ing a Web brow ser at a different Web sit e. Wit h a broader adopt ion of Web services and XML docum ent form at st andards, t his st yle of dynam ic business part ner int egrat ion w ill becom e m ore broadly used. When syst em s are t his easy t o int egrat e, an organizat ion's reach t o suppliers, cust om ers, and ot her business part ners is ext ended, yielding cost savings, flexible business m odels, bet t er cust om er service, higher cust om er ret ent ion, and so on. Just as I T is fundam ent al t o t he efficient operat ions of an organizat ion, Web services- based syst em s int egrat ion w ill be fundam ent al t o flexible, light w eight syst em s int egrat ion—for int ernal applicat ion int egrat ion w it hin an organizat ion over an int ranet and ext ernal part ner int egrat ion over t he I nt ranet or ext ended virt ual privat e net w ork. So, from a business perspect ive, a Web service is a business process or st ep wit hin a business process t hat is m ade available over a net w ork t o int ernal and/ or ext ernal business part ners t o achieve som e business goal.

Technical Perspective

  From a t echnical perspect ive, a Web service is not hing m ore t han a collect ion of one or m ore relat ed operat ions t hat are accessible over a net w ork and are described by a service descript ion. At t his level, t he Web services concept is not new . Wit h Web services, t he I T indust ry is t rying t o address t he fundam ent al challenge of dist ribut ed com put ing t hat has been around for decades—locat ing and accessing rem ot e syst em s. The big difference is t hat now t he indust ry is approaching t his problem using open t echnology ( XML and I nt ernet prot ocols) and open st andards m anaged by broad evolut ion of t he SOAP and WSDL specificat ions) . Furt her, t he approach oft en t aken w it h Web services uses capabilit ies- based lookup , w here t he kind of service is searched for, as opposed t o a service of a part icular nam e or obj ect ident ifier.

The Web Service Opportunity

  The Web services approach is an applicat ion int egrat ion concept ; it is a set of t echnologies t hat provides access t o business funct ionalit y, such as purchase order processing. Oft en, t he business funct ionalit y already exist s in t he form of legacy t ransact ion processing syst em s, exist ing Web applicat ions, Ent erprise Java Beans, and so on. Web services t echnology is about access and applicat ion int egrat ion; it is not an im plem ent at ion t echnology.

  Organizat ions use Web services t echnology in t w o broad cat egories: Ent erprise Applicat ion I nt egrat ion ( EAI ) and business- t o- business ( B2B) part ner int egrat ion over t he I nt ernet . I n eit her of t hese cat egories, Web services can range in sophist icat ion from sim ple request response funct ions such as a credit card check t o very com plicat ed m ult i- part y, m ult i- st age long- running business t ransact ions such as a supply configurat ion and order syst em . Web services can be invoked by PC- based program s, m ainfram e syst em s, Web browsers, or even sm all m obile devices such as cell phones or personal digit al assist ant s ( PDAs) .

  Regardless of t he applicat ion, Web services w ill be used for syst em s int egrat ion: flexible, loosely- coupled syst em s int egrat ion yielding syst em s t hat can be decom posed and recom posed t o reflect changes in t he business.

Enterprise Application Integration

  Ent erprise Applicat ion I nt egrat ion is st ill a field w here large consult ing com panies com m and m ult im illion dollar cont ract s t o help t heir client s deal w it h a m ess of applicat ions t hat w ere never m eant t o int eroperat e. The st at e of t he art wit hin m any ent erprise syst em s rem ains t hat of large, m onolit hic applicat ion " silos." These syst em s are oft en ext rem ely difficult t o change, let alone int egrat e w it h ot her syst em s. These applicat ions oft en define unique dat a form at s, and som et im es ( for hist orical, oft en perform ance- relat ed reasons) even define t heir ow n com m unicat ions prot ocols. Furt herm ore, m any syst em s, part icularly in large organizat ions, can exist on m ult iple different plat form t echnologies. I nt eroperabilit y bet w een syst em s is a significant challenge. I n m any organizat ions, part icularly organizat ions t hat result from a m erger of t w o previously independent com panies, I T int egrat ion cost s can seriously im pact t he financial healt h of t he com pany. The Web services approach offers an at t ract ive set of t echnologies by w hich exist ing legacy syst em s can be w rappered as Web services and m ade available for int egrat ion w it h ot her syst em s w it hin t he organizat ion. Applicat ions exposed as Web services are accessible by ot her applicat ions running on different hardw are plat form s and w rit t en in different program m ing languages. Using t his approach, t he com plexit y of t hese syst em s can be encapsulat ed behind indust ry- st andard XML prot ocols. Pair- w ise syst em int egrat ion proj ect s can be replaced w it h one- t o- m any syst em s int eract ions based on Web services. The prom ise of higher- level int eroperabilit y init iat ives is t hat over t im e w e w ill be able t o develop t he set of st andards, t echnologies, and t ools t hat w ill enable sm all and large businesses all over t he w orld t o easily int egrat e syst em s int ernally, and t hen m ix and m at ch t he im plem ent at ion of various act ivit ies w it hin a business process, m aint aining t he opt ion t o, at any t im e, choose t o out source any or all of t hese act ivit ies if doing so m akes business sense.

  For m any organizat ions, t heir first im plem ent at ions using Web services t echnology w ill be w it h I T. Flexible syst em s w ill yield flexible business m odels. Flexible business m odels w ill yield organizat ions bet t er able t o adapt t o changes in t he business environm ent .

B2B

  Anot her key driver behind t he rise of Web services is t he cont inuing evolut ion of B2B com put ing. B2B com put ing is about int egrat ing t he business syst em s of t w o or m ore com panies t o support cross- ent erprise business processes such as supply chain m anagem ent . Som e indust ry pundit s claim t hat supply chain int egrat ion w ill be t he killer applicat ion of Web services, part icularly as a result of t he st andardizat ion of com m on indust ry form at s for XML and Web services relat ed t o supply chain business processes. B2B applicat ions can be as sim ple as aut om at ed credit card validat ion or as com plex as t he full aut om at ion of t he m ult i- billion- dollar supply chain of a Fort une 100 com pany. The challenges of building B2B applicat ions com bined w it h t heir huge m arket pot ent ial drove rapid innovat ion t hat has t aken t he indust ry from sim ple business- t o- consum er ( B2C) applicat ions t o SOAP- enabled Web services in a m at t er of five years. B2C, B2B, and Web services Online HTML- based applicat ions are consum er- orient ed. The classic exam ple of a B2C Web applicat ion is t he Am azon book search. To access t his funct ionalit y, a hum an being needs t o use a Web brow ser t o navigat e t he com pany's sit e t hrough m ult iple page t ransit ions, input inform at ion using Web form s, subm it t hem , and get t he result s back in hum an- readable form . The only w ay t o aut om at e t his process is t o sim ulat e how a hum an uses t he syst em . Doing so involves reverse- engineering t he Web applicat ion t o see how it m oves dat a bet w een pages, passing t he dat a aut om at ically from page t o page, and, finally, parsing any dat a cont ained in t he response HTML of pages. This screen- scraping approach w as popular in t he early years of t he Web ( 1995–97) . I t is very error prone. Any changes in t he Web applicat ion—even changes t hat are com plet ely UI - cent ric and do not change t he dat a being passed back and fort h—can break screen- scraping applicat ions. These problem s are com pounded because m ost of t hese applicat ions do not properly separat e present at ion from applicat ion processing logic. The only t rue w ay t o int egrat e applicat ions on t he Web is t o use a B2B- focused solut ion. Because B2B applicat ions are designed t o have ot her applicat ions as t heir client s, t hey are fundam ent ally different from B2C applicat ions. Table 1.1 sum m arizes som e of t hese differences for Java applicat ions. Bot h t ypes of applicat ion are unrest rict ed as t o t he t ype of backend t hey can use—t ypically, Java classes or Ent erprise Java Beans ( EJBs) . ( We discuss how Web services w ork w it h EJBs in m ore det ail in Chapt er 5 , " Using SOAP for e- Business." ) This is where t he sim ilarit ies end, however. To cust om ize backend logic, B2C applicat ions use servlet s or Java Server Pages ( JSPs) t hat are host ed in a servlet engine. B2B applicat ions cust om ize t heir backends using st raight Java code ( oft en EJBs) t hat is host ed inside a Web service engine. B2C applicat ions com m unicat e w it h a brow ser over HTTP. B2B applicat ions can use any of t he open I nt ernet prot ocols such as HTTP, SMTP, or FTP, or propriet ary net w orks such as EDI . B2C applicat ions handle dat a over t he st raight HTTP prot ocol. I nput com es as GET param et ers ( on t he URL/ query st ring) or as POST param et ers from Web form s. Only st rings can be exchanged. Any ot her dat at ypes, even num bers, need t o be encoded as st rings. For out put , dat a is m ixed t oget her w it h form at t ing rules inside HTML pages. This is in m arked cont rast w it h B2B applicat ions t hat use XML for bot h dat a input and out put . XML is perfect for B2B com put ing because it is program m ing language- and plat form - neut ral, it can represent arbit rary dat a st ruct ures, it is easy t o process, and it can be validat ed independent ly of it s processing. B2C applicat ions need t o have som e UI ( t ypically HTML, alt hough som e have used Java applet s) because t heir client s are hum ans. B2B applicat ions have no UI because t heir client s are ot her applicat ions.

Table 1.1. Comparing B2C and B2B Java Applications

Area B2C application B2B application

  Backend logic Java classes and EJBs Java classes and EJBs Custom logic Servlets and JSPs Web service engine Communication HTTP HTTP, SMTP, FTP, TCP/IP, EDI, protocol JMS, RMI/IIOP… Data input HTTP GET/POST

  XML parameters Data output HTML

  XML UI HTML + script N/A Client Human behind a Software application browser

Trends in e-business I t is clear t hat t he net w ork econom y is current ly driving t he evolut ion of business

  Businesses m ust respond t o increasingly dynam ic m arket places. Wit hin corporat e depart m ent s, applicat ion int egrat ion has been a m aj or issue in t he last few years. Tradit ional archit ect ures are brit t le, and t his brit t leness is being exposed as t he scale, dem and level, t ransact ion volum e, and rat e of change of t ransact ion volum e increases.

  I nt eroperabilit y, part icularly bet w een het erogeneous dist ribut ed syst em s com ponent s, has been one of t he m aj or t hem es in soft w are engineering in general, and EAI in part icular, for t he last decade. I t 's unfort unat e t hat t he seam less int eroperabilit y vision is st ill a dream . Brit t leness in all current archit ect ures is prevent ing soft w are from achieving t his vision. Brit t leness com es from t ight ly coupled syst em s t hat generat e dependencies at every level in t he syst em . One of t he m ost im port ant lessons w e learned as developers and archit ect s is t hat syst em s need t o be able t o find resources ( soft w are or ot herwise) aut om at ically, w hen and as needed, w it hout hum an int ervent ion. This abilit y frees business people t o concent rat e on t heir business and cust om ers rat her t han w orry about