9
Rochester Institute of Technology RIT Scholar Works Presentations and other scholarship Faculty & Staff Scholarship 2004 Design paerns for web service Kai Qian Orlando Karam Jorge Diaz-Herrera Jigang Liu Follow this and additional works at: hps://scholarworks.rit.edu/other is Conference Paper is brought to you for free and open access by the Faculty & Staff Scholarship at RIT Scholar Works. It has been accepted for inclusion in Presentations and other scholarship by an authorized administrator of RIT Scholar Works. For more information, please contact [email protected]. Recommended Citation Kai Qian, Orlando Karam, Jorge Diaz, Jigang Liu: Design Paerns for Web Services. SNPD 2004: 342-348. International Association for Computer and Information Science (ACIS)

Design patterns for web service - RIT Scholar Works

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Design patterns for web service - RIT Scholar Works

Rochester Institute of TechnologyRIT Scholar Works

Presentations and other scholarship Faculty & Staff Scholarship

2004

Design patterns for web serviceKai Qian

Orlando Karam

Jorge Diaz-Herrera

Jigang Liu

Follow this and additional works at: https://scholarworks.rit.edu/other

This Conference Paper is brought to you for free and open access by the Faculty & Staff Scholarship at RIT Scholar Works. It has been accepted forinclusion in Presentations and other scholarship by an authorized administrator of RIT Scholar Works. For more information, please [email protected].

Recommended CitationKai Qian, Orlando Karam, Jorge Diaz, Jigang Liu: Design Patterns for Web Services. SNPD 2004: 342-348. International Associationfor Computer and Information Science (ACIS)

Page 2: Design patterns for web service - RIT Scholar Works

Proceedings of the ACIS5th ACIS International Conference on Software Engineering,Artificial Intelligence, Networking and Parallel/Distributed

Computing (SNPD 2004)

June 30 — July 2, 2004People's Palace Hotel, Beijing, China

Editors

Gongzhu Hu, Central Michigan University, USATao Huang, Institute of Software Chinese Academy of Science, ChinaXizhen Ni, Institute of Software Chinese Academy of Science, China

Aoying Zhou, Fudan University, China

ISBN: 0-9700776-8-8

A Publication of the International Association for Computer and Information Science (ACIS)URL: http://acis.Isfk.org E-mail: [email protected]

Page 3: Design patterns for web service - RIT Scholar Works

5th ACIS Inte.national Conference on SNPD, June 30-July 2, 2004, Beijing, China

Design Patterns for Web Service

Kai Qian Orlando Karam Jorge Diaz Jigang LiuDept. of Software Dept. of Computer College of Computing Dept. of Computer

Engineering . Science and Information ScienceSouthern Polytechnic Southern Polytechnic Science Metropolitan State

State University, U.S.A. State University, U.S.A Rochester Institute of University, U.S.ATechnology, U.S.A

Abstract

Web service technology is a component-oriented SOAPbased interoperable technology widely used in enterpriseApplication to Application (A2A), Business to Business(B2B), and EAl. Web Service component composite andconnection models are the key issues to make Web servicesuccessful in the future. This paper presents a number ofWeb service compositions and connection patterns whichwill facilitate the Web service design.

Key words: component, design pattern,. Web service,proxy, composite, adapter

Introduction

Web service is a new paradigm to deliver applicationservices on Web and enables a programmable Web notjust an interactive Web. Web service is the thirdgeneration in Web evolution after static HTML andinteractive Web development such as PERL, ASP, JSP,.and others. Web services are a typical black box reusablebuilding block components in distributed computing.There are many other distributed component frameworksavailable in industry such as CORBA, MS DCOM,.NET, EJB but only Web service provides a realcross-platform, cross programming languages, cross proprietaryrestriction, and internet firewall friendly solution tointeroperable distributed computing. We can simply saythat Web services is a self-descriptive on-line distributedcomponent which exposes its services and functionalityvia its interface on-line and can be published, located andinvoked programmatically over Internet. A key point ofthe importance of Web services is its ability to supportprogrammatic end points for any . applications to getservices provided by any Web services on line [1 -3].

One philosophy behind Web services is to shiftdistributed software developments from programming tocompositions, from coding ground up to building fromexisting components either by purchasing or by reusingexisting components. This is exactly the advantage of

Component-Oriented Programming (COP) andComponent Based Software Engineering (CBSD). So themain goal of Web services is not only to provide serviceson Web but also to provide a mechanism to share itsservice as a building block to be. part of other Webservices or application programs via its programmaticWeb services end points. Web service has shown thepotentials to change the ways of enterprise businessmodeling in distributed system interactions. A largeenterprise system can be divided into many relativelyindependent Web services components, which in turn getservices from other Web services components, deployedon Internet.

The key issues to make Web service be a nextgeneration of distributed computing successfully are theintegration, interaction, connection, and compositionmodels of the Web services. Many GoF design patternscan be applied to Web service application design. [10]The next sections discuss the composition patterns, proxypatterns, and the other applicable patterns.

2. Design patterns

Design patterns are a set of rules of how to structurecode in order to solve a particular class of problems.Many complex software systems needs a number ofdesign patterns working together A design pattern is alsoa solution to a common software problem which can beapplied in many similar cases. A design pattern has itscontext, and guideline. Comparing to architecture designthe detail pattern oriented design is kind of micro-architecture design and architecture design is a macrodesign which is conducted before detail design. Patternoriented design is a 00 design methodology which reusesthe patterns they have been used many times beforeinstead of design from first principles. Since patternoriented design is the blueprint of software codedevelopment so it is a high level programming idiom.

The design patterns can classified into two diminutioncategories: scopes and usage. The scope of design

342

Page 4: Design patterns for web service - RIT Scholar Works

5th ACIS International Conference on SNPD, June 30-July 2, 2004, Beijing, China

patterns can be at class level pattern, object level pattern,and component level pattern. In term of wage concern,there are creatural pattern concerning construction such asfactory and singleton, structural patterns concerningcomposition such as composite and proxy, and behavioralpattern concerning the interaction such as iterator andobserver.

2. Composite Patterns for Web Service

2.1 Composite patterns

The composite pattern is one of the most popularpatterns used to construct a compound component, InJava API a container component class is a sub class ofAWT component class, There are many similar AWTcomponent classes in this part-whole hierarchy. Acomposite itself may be a component. A component maybe a composite component or primitive component. Thecontainer component object is a compound component,which can add another component that in tern can beanother container or a primitive component. This conceptcan be applied to component design beyond class designand object design. There arc two alternatives in compositepatterns. A component in a composite component mayknow which component it belongs to, This kind ofcomponent can be accessed directly from the client of thecomposite where the component resides. It is called acontainment composition. The other type of componentmay not know itself which composite it belongs to. It cannot be directly accessed from outside. It is calledaggregation composition. Figure 1 below shows a generalUML of a composite pattern.

Figure 1 Composite pattern

2.2 Composite patterns in WebserviceWe have seen Web Service applications that a client

simply gets a service from a primitive Web service.Actually we can also compose a new Web service frommany existing Web services. In order to make Webservice be truly useful in A2A, B2B and EAI, there mustbe a way to combine and coordinate collections of Webservices, to glue them together, so that they can beintegrated to support a large scale real world businessenterprise application A new compound Web service,which has its own identification, is called composite Webservice and is different from primitive Web service. OneWeb service can be composed irto many other Webservices and one Web service may consist of many Webservices.There is a many-to-many relationship between a Webservice and Web service composition. There are twocomposed Web services in Figure 2. Both of them usews3 as a part of their Web services. We can see that acomposite Web service is a Web service which combinesor glues multiple Web services into a new large Webservice.Web Service Flow Language (WSFL) [1] 12] may be usedto determine the sequence of sub process of Web servicesthat form a business process and flow of information.

Figure 2 Web service composite

A Web service composite can be implemented by acontainment construction, in which the outer Web serviceholds a reference to one or many inner Web services andouter Web service forwards a Web service request to ainner Web service. The endpoint of inner Web service isbehind the scene. An example of containmentconstruction is the Web service end point for statelesssession B shown in Figure 3.

Figure 3 Web service composite (containment)for a J2EE enterprise application

343

Page 5: Design patterns for web service - RIT Scholar Works

5th ACIS International Conference on SNPD, June 30-July 2, 2004, Beijing, China

A Web service composite can also be implemented byaggregation construction, in which an inner Web serviceend point reference is handed out directly to the outerWeb service client. Figure 4 shows both of thesecompositions are hardwired at the design time.

Figure 4 Web service composite (aggregation) of Webservice composition

3. Web service interaction models

Web service invocation is done in either synchronous orasynchronous mode. in the synchronous interaction, aclient sends a Web service request and halts its operationwhile waiting for a response. If the service takes atremendous computation time to complete or the serviceis not needed until some events are triggered anasynchronous interaction must be used instead. Thesynchronous interaction is the default interaction in Webservice operations. Another reason is in some cases thereis no backward channel available for the responses tocome back synchronously such as email response to aHTTP request.

Asynchronous message-based operation is a singlemessage passing operation, which can be one-wayincoming notification and one-way outgoing notification.One-way message passing operation never expects anyresponse right away. The message may be a signal, anotification, or data to be processed by the target of themessage. The two-way out/in request/response operationis a RPC-based operation with combination of incomingand outgoing SOAP message. Thesource of the messagesends out an outgoing SOAP message and expects to getan incoming response SOAP message bacright away. Inthe in/out (solicit/response) mode the target of messagegets incoming SOAP message and responds an outgoingSOAP message. Obviously, they are synchronousoperations. Figure 5 shows these four types of interactions

between any two Web service components or betweenWeb service clients (may be a web service itself) and aWeb service component.

Figure 5 WSDL supported interaction pattern

4, Proxy patterns in Web Services

4.1. Proxy pattern

The proxy pattern is often used to represent a remoteobject, or component that is complex, or time consumingto create, or to enforce access control to that object. Itpasses on method calls from client s to an actual target. Itis a surrogate placeholder of real object or component. Aproxy acts on the behalf of another object or component.A proxy does not provide service directly but callsmethods of the actual object or component, whichprovides the needed services. In a distributed computingenvironment a proxy marshals the method call invocationto serialize it to a remote service and unmarshals theresponse back from the remote server. The followingFigure 6 (a) shows the concepts of a proxy. We focus onthe proxy class on client side at this time. The proxy mayreside at server side too. There may also be many types ofproxies such as remote proxy, virtual proxy, protectionproxy, dispatcher proxy, and each proxy can associatewith some other design patterns such as adapter, bridge,dispatcher, and factory. In the following section we focuson the proxy patterns used in Web services. The Part (b)of the figure shows a Web service static proxy pattern,which will be discussed later,

344

Page 6: Design patterns for web service - RIT Scholar Works

Figure 7 Web service dynamic proxy

5th ACIS International Conference on SNPD, June 30-July 2, 2004, Beijing, China

a) Proxy pattern

(b) Web service static proxy

Figure 6 Proxy patterns

4.2 Web service static stub proxy

A static stub proxy is created at the compilation time andall related information about Web service including URL,WSDL, service name, port, and even the implementationof the Web service component are known. The staticproxy is a representative of the remote Web servicecomponent and knows how to handles the request to theserver component and response back from the servercomponent. It is very efficient but it not portable at allbecause it is implementation specific. The figure 6 (b)depicts the concept of a Web service static stub proxyclass. The part above dash line indicates the compilationtime and the part below indicates the run time. The parton the left side of dash line describe the client and theright side describes the Web service .

4.3 Web service dynamic proxy

In some cases the WSDL of a Web service may notavailable at the compilation time or it got changedafterward. A dynamic proxy is generated at run timeinstead of compilation time to avoid such problems. Aftercollecting all necessary information about WSDL andlooking for WSDL to get detail information to generate adynamic proxy which is more portable and less efficientin term of performance. In this case the client still needsto know all details of signatures of the remote method. Itis a generic service proxy which supports multipleimplementation options. In some scenario, one Webservice interface may have multiple implementations orbindings. The client may also want to use differentimplementations in term of protocols for same interfacespecification. Figure 7 shows the Web service dynamicproxy pattern where left part of dash line is client andright side of dash line is Web service, and the part abovethe dash line indicates the compilation time and the partbelow the dash line indicates the run time.

345

Page 7: Design patterns for web service - RIT Scholar Works

5th ACIS International Conference on SNPD June 30-July 2, 2004, Beijing, China

4.4 Web service Dynamic Invocation Interface

(DII) proxy

The DII proxy is even more portable than dynamicproxy where the client can call remote methods of a Webservice even if the signature of the remote method orname of the service are unknown until run time.

At the time Call object proxy is coated it is not yetassociated with any operation. Next, all operationproperties including the Web service end point address,method name, arguments, operation style such as "rpc"can be set or added to the Call object. For example a Webservice client application can provide all neededinformation via command line arguments withoutknowing anything about target Web service in advance.The trade-off of it is the performance again. This DIImodel is very similar to DII in CORBA.[12]

Figure 8 Dynamic Invocation Interface (DII)

4.5 Web service two way asynchronous virtual proxy

An asynchronous communication does not expect to getresponse immediately instead it can continue its workwithout being idle in waiting for a notification from theserver. There are many way to implement such ascallback method which passes in a callback method as anargument of remote method invocation to a servercomponent and lets server component calls back thiscallback method when it is ready. Other option can beimplemented in a half asynchronous mode. The client stillneeds to poll expected results from a queue where theserver puts the response. Figure 8 shows theasynchronous invocation pattern for a Web service clientto. get a service provided by a Web service at a server site.

main()

(b) Asynchronous WS pollingFigure 9 Asynchronous two way poll proxy

The part (a) of Figure 9 depicts a threaded proxy patternwhere client pawns a thread to take care of invocation to

346

Page 8: Design patterns for web service - RIT Scholar Works

scan

5th ADS International Conference on SNPD, June-30-July 2, 2004; Beijing, China ;

remote methods and notifications back from . Web service.The part (b) of the figure depicts a half asynchronouspolling pattern where client and server are decoupled by amessage queue. The client places arequest onto the queueand server picks up the request from the queue and thenserver enter the results onto the queue and lets client topoll the result asynchronously.We assume that -the client is not a Web service

component in this section, Figure ID shows a scenario thatboth of client and server are Web services.

handlers of corresponding targets will be invoked. Theremay be many listeners register with a single event source.The trigger of the event may be a third party.

The WSDL1.0 spec does not support event interactionmodel. Some Web service vendors are implementingevent-based notification which is similar to apublish/subscribe pattern. The solutions are eitherWSDL is enhanced to support event type or two way

asynchronous modes, or Web service implementation APIsupports the event handling mechanisms.

Figure 10 Web service callback proxies

5. Event-based patterns in Web service

The event -based asynchronous communication betweenevent source component and even target component isvery popular in event-based applications and also widelyused in distributed computing such as CORBAComponent Model (CCM). Figure 11 shows theconceptual event-based pattern where the event targetmust register with event source and specify the eventhandler which takes an event type object. Whenever suchevent is triggered the event source will scan the vectorwhere all interested targets are registered and the event

Figure 11 Event-based patterns

6. Adapter pattern in Web service

The adapter pattern is used to convert one interface toanother interface in different infrastructure. The idea is togenerate a class, object, or component that has the desiredinterface and make it communicate with the class, object,or component that las a different interface. Figure 12shows the concept of the adapter pattern at class levels.We can derive a new class from an adaptee class and addnew methods to make the new derived class match thetarget one.

347

Page 9: Design patterns for web service - RIT Scholar Works

5th ACIS international Conference on SNPD, June 30-July 2, 2004, Beijing, China

Figure 12 Gateway/Adapter

Of course we can use create a new class which includesthe adaptee class and create a method to translate the callwithin the new one. This pattern can be used for objectadapter pattern. A Web service needs to work with otherexisting application in different technology, protocol, andinfrastructure. There is a need to generate an adaptereither at client side or server side just Iike the figure 13shows. Even there is a need to have an adapter betweentwo Web service components because of differentimplementations from different Web service vendors.

7. Conclusion

En this paper we present a number of applicable designpatterns for Web service constructions many other designpatterns can also be applied in Web service designtogether such as factory, thread-safe, dispatcher, andproxy patterns. We also propose a CCM type event-baseddesign pattern which will enhance the Web serviceapplications. The design pattern is one of the veryeffective methodologies applied to the detail design phaseof Web service engineering,

8. References

[1] F. Curbera, I Silva-Lepe, and S Weerawarana, "On theIntegration of Heterogeneous Web Service Partners", 2001[2] R Srivastava, and J Koehler, "Web Service Composition –Current Solutions and Open Problems", 2002[3] F. Curbera, N Mukni, and S Weerawarana, "On theEmergence of a We b Services Component Model", 2001[4] H. Deitel, Java Web Services for Experienced Programmers,Prentice Hal], 2003[5] H. Deitel, Web Services, a technical Introduction, PrenticeHalf, 2003[6] M. Clark, P. Fletcher, J. J. Hanson, R Irani, M. Waterhouse,and J. -Melia, "Web Services Business Strategies andArchitectures", 2002[7]http://msdn.microsoft.com/library/en-us/cptutorials/html

[8]http://www.componentsource.com

[9]http://www.codeproject.com

[10] Gamma, Heim, Johnson, Vissides, "Design patterns",Addison-Wesley, 1998[11] Mark, Grand, "Patterns in Java", John Wiley & Sons, 1996[12] T. Mowbray, and R. Malveau, "CORBA Design Patterns",John Wiley & Sons, 1997

348