Service-Oriented Software Development (SOSD) based on Service-Oriented Architecture (SOA) and Service-Oriented Computing (SOC) represents modern software engineering practices and technologies. The first edition of the book covered the concepts, principles, methodology, and the latest technologies in SOSD. As SOSD is still a rapidly developing young field, many new concepts as well as technologies have emerged since the publication of the first edition of the book two years ago. In the new edition of the book, we have embraced a large of part of the new knowledge, including concepts, principles, and technologies developed in the past two years. Five new chapters are added and all the other chapters have been significantly revised and extended. The new chapters are: Chapter Five on Web application and data management, which discusses stateful Web application development using different state management techniques, including view state, session state, application state, file management, and Web caching. Chapter Seven on service-oriented and resource-oriented computing, which introduce Web service development, service hosting, and RESTful service development in Windows Communication Foundation. Chapter Nine on service-oriented computing in robotics applications, which studies Visual Programming Language (VPL) and uses it develop robotics services and applications. Distributed robotics applications and Robot-as-a-Service (RaaS) are also presented. Chapter Ten on service-oriented database management, which presents interface between service-oriented software and relational database, XML database, and LINQ (Integrated Language Query) and using LINQ to access object, relational database, and XML database. Chapter Fourteen on cloud computing, which introduce the most recent trend in SOC, and it covers multi-tenancy architecture, Web databases and file systems, scheduling, fault-tolerant techniques, and real-time computing. It also presents cloud computing platforms and development environments from Google, Microsoft, and Salesforce.com, with the Software-as-a-Service as the main focus. . We organize the chapters into three parts, each of which can be used in a different course. Part One includes the first six chapters, which can be used for a service-oriented computing and distributed software development course at the senior level or graduate level of universities. This part emphasizes the computing paradigm, data representation and management, and programming language-based software development. It introduces fundamental concepts and principles, in addition to technologies and tools, that have not been taught in traditional software engineering courses, such as multithreading, event-driven programming, service-oriented development, Web-based programming, Web data management, and reliability and security mechanism development. Part Two includes the next nine chapters. These chapters are built on the basic concepts and principles discussed in Part One, yet they do not rely on the detail of the first six chapters. This part emphasizes composition of enterprise-level data management and applications using services and large components. It covers Web service and RESTful service development in Windows Communication Foundation, Business Process Execution Language (BPEL) for enterprise software development, Visual Programming Language (VPL) for event-driven software development and robotics applications, interfacing service-oriented software to databases, ontology languages and applications, service-oriented application architecture, cases studies, and cloud computing. The materials can be used for a senior or graduate course. While most contents in Part Two are based on matured knowledge and technologies, many research questions are also discussed to help graduate students to identify their research directions and topics. Part Three contains tutorial-based materials that provide step-wise instructions to build a working application from scratch. The materials in this part are critical to students who are learning Part One and Part Two with insufficient programming background. These tutorials and exercises can simply help these students to connect the concepts and turn them into working programs. This part can be used for a freshman level course to introduce computing concepts through game programming, robotics programming, and Web programming. At Arizona State University, we use the book as the text for two courses. The first course is CSE445/598 (Distributed Software Development), where the CSE445 session is for seniors and the CSE598 session is for graduate students. This course mainly teaches the contents from the Part One. Biweekly programming assignments and projects are given from assignments and projects at the end of each chapter. We also use the book for a newly developed course CSE494/598 (Service-Oriented Computing and Information Management), which teaches from the contents of Part Two. These two courses can be taught independently without making one to be the prerequisite of the other. However, basic concepts and principles from Part One, including those from Chapter One, Chapter Three, and the first section of Chapter Four, should be reviewed or be assigned as reading materials for preparing the required concepts to start Part Two. We like to thank many of our sponsors, supporters and colleagues in this project, particularly in preparing the second edition of the book, including Prof. Xiaoying Bai of Tsinghua University, Dr. Shuyuan Chen of SAP, Dr. J. Y. Chung of IBM, Prof. Zhihui Du of Tsinghua University, Mr. Marcos Garcia-Acosta of Intel, Prof. Mei Hong of Peking University, Dr. K. W. Hwang of IBM, Prof. Zhi Jin of Peking University, Prof. Y. H. Lee of Arizona State University, Prof. Yisheng Li of Fudan University, Mr. John Oliver of Intel, Dr. Raymond Paul of DoD OSD NII, and Prof. S. S. Yau of Arizona State University, Prof. Lian Yu of Peking University. They contributed to our understanding of the materials. We also acknowledge the generous support from Intel, U.S. Department of Education, U.S. Department of Defense, and National Science Foundation. Without their support, this book will not be possible. We also thank the teaching assistants and research assistants at Arizona State University involving Jay Elston, Wu Li, Guanqiu Qi, Qihong Shao, Xin Sun, Le Xu, and Peide Zhong. They validated many of the examples and assignments used in the book. Finally, we would like to thank our families for their support and understanding of taking on such a project while carrying out a full research and teaching load at the university. Note for Instructors All the assignments and projects have been classroom-tested at Arizona State University. Furthermore, all the code presented in this book has been developed and tested. Contact the authors if you are interested in obtaining more materials in this book. This book also has a corresponding website at http://asusrl.eas.asu.edu/share/services/book/ where you can download resources related to this book. Instructor-only resources can be obtained by directly contacting the authors at {yinong, wtsai}@asu.edu. Yinong Chen Arizona State University Wei-Tek Tsai Arizona State University Tsinghua University


Table of Contents

Part I Distributed Service-Oriented Software Development and Web Data Management

Chapter 1 Introduction to Distributed Service-Oriented Computing 2
1.1 Computer Architecture and Computing Paradigms 2
1.1.1 Computer Architecture 2
1.1.2 Software Architecture 3
1.1.3 Computing Paradigms 4
1.2 Distributed Computing and Distributed Software Architecture 6
1.2.1 Distributed Computing 7
1.2.2 N-Tier Architecture 8
1.2.3 Distributed Object Architecture 10
1.3 Service-Oriented Architecture and Computing 12
1.3.1 Basic Concepts and Terminologies 12
1.3.2 Service-Oriented Computing 16
1.3.3 Object-Oriented Computing versus Service-Oriented Computing 18
1.3.4 Service-Oriented Enterprise 21
1.3.5 Service-Oriented System Engineering 22
1.4 Service-Oriented Software Development and Applications 24
1.4.1 Traditional Software Development Processes 24
1.4.2 Service-Oriented Software Development 24
1.4.3 Applications of Service-Oriented Computing 27
1.4.4 Web Application Composition 29
1.5 Discussions 30
1.6 Exercises and Projects 35
Chapter 2 Distributed Computing with Multithreading 44
2.1 Introduction to C# and .Net 44
2.1.1 Getting started with C# and .Net 45
2.1.2 Comparison between C++ and C# 47
2.1.3 Namespaces and the using Directive 49
2.1.4 The Queue Example in C# 51
2.1.5 Class and Object in C# 53
2.1.6 Parameters: Passing by Reference with ref & out 56
2.1.7 Base Class and Base Calling Class Constructor 57
2.1.8 Constructor, Destructor, and Garbage Collection 57
2.1.9 Pointers in C# 58
2.1.10 C# Unified Type System 59
2.2 Memory Management and Garbage Collection 60
2.2.1 Static Variables and Static Methods 61
2.2.2 Runtime Stack for Local Variables 62
2.2.3 Heap for Dynamic Memory Allocation 64
2.2.4 Scope and Garbage Collection 64
2.3 General Issues in Multitasking and Multithreading 65
2.3.1 Basic Requirements 65
2.3.2 Critical Operations and Synchronization 66
2.3.3 Deadlock and Deadlock Resolving 69
2.3.4 Order of Execution 70
2.3.5 Operating System Support for Multitasking and Multithreading 71
2.4 Multithreading in Java 73
2.4.1 Creating and Starting Threads 73
2.4.2 Thread Synchronization 77
2.4.3 Synchronized Method 78
2.4.4 Synchronized Statements 82
2.5 Multithreading in C# 83
2.5.1 Thread Classes and Properties 83
2.5.2 Monitor 84
2.5.3 Reader and Writer Locks 94
2.5.4 Mutexes 98
2.5.5 Semaphore 99
2.5.6 Coordination Event 99
2.6 Exceptions Handling and Event-Driven Programming 102
2.6.1 Exception Handling 102
2.6.2 Event-Driven Programming 107
2.6.3 Case Study: An Electronic Commerce Application in Event-Driven Approach 113
2.7 Discussions 119
2.8 Exercises and Projects 120
Chapter 3 Essentials in Service-Oriented Software Development 133
3.1 Overview of Service-Oriented Software Development Environments 133
3.2 Service Provider: Creating and Hosting Services 135
3.2.1 Using ASP .Net to Create Web Services 136
3.2.2 Program Your Services in C# 137
3.2.3 Testing Your Web Services 138
3.2.4 Hosting Your Web Services as a Service Provider 139
3.3 Service Brokers: Publishing and Discovering Services 141
3.3.1 An Ideal Service Broker with all Desired Features 142
3.3.2 UDDI Service Registry 145
3.3.3 ebXML Service Registry and Repository 153
3.3.4 Ad Hoc Registry Lists 155
3.4 SOAP 156
3.4.1 SOAP Format 156
3.4.2 SOAP Over HTTP 157
3.5 WSDL: Web Service Description Language 158
3.5.1 Elements of WSDL Documents 159
3.5.2 WSDL Document Example 160
3.6 Service Requesters: Building Applications Using Services 162
3.6.1 Connecting Endpoint and Proxy 162
3.6.2 Creating a Web Application Project in ASP.Net 163
3.6.3 Creating GUI and Composing an Application Based on Remote Web Services 165
3.7 Java-Based Web Service Development 172
3.7.1 Web Application Building Using AJAX programming 172
3.7.2 Java-Based Web Service Development and Hosting 174
3.8 Discussions 176
3.9 Exercises and Projects 178
Chapter 4 XML Data Representation and Processing 184
4.1 XML 185
4.1.1 XML versus HTML 185
4.1.2 XML Syntax 186
4.1.3 XML Namespaces 189
4.2 XML Data Processing 190
4.2.1 DOM: Document Object Model 191
4.2.2 SAX: Simple API for XML 193
4.2.3 XML Text Writer 195
4.2.4 XML Processing in Java 196
4.3 XPath 198
4.4 XML Type Definition Languages 201
4.4.1 XML Document Type Definition (DTD) 201
4.4.2 XML Schema 204
4.4.3 Namespace 206
4.4.4 XML Validation 209
4.5 Extensible Stylesheet Language 210
4.6 Other Web Data Formats 216
4.6.1 XHTML 217
4.6.2 Google Protocol Buffers and BigTable 218
4.7 Discussions 220
4.8 Exercises and Projects 221
Chapter 5 Web Application and Data Management 227
5.1 Structure of Web Applications 227
5.1.1 Components of Web Applications 227
5.1.2 Server Controls 230
5.1.3 User Controls 234
5.1.4 Web Application Configuration 236
5.1.5 Global Application Class 239
5.1.6 Dynamic Link Library 241
5.2 Models of Web Applications 242
5.2.1 Pure HTML based Web Application 242
5.2.2 Client Side Scripting 242
5.2.3 Server-Side Scripting and Code-Behind Page Computing 244
5.3 State Management 246
5.3.1 Overview of State Management Techniques 246
5.3.2 View State 247
5.3.3 Session State 248
5.3.4 Session State and Cookies 252
5.3.5 Application State and Service Execution Model 253
5.4 Save User Data to Server File System 254
5.4.1 File System and Standard File Operations 254
5.4.2 Reading and Writing XML Files 255
5.5 Caching 260
5.5.1 Output Caching 261
5.5.2 Fragment Caching 262
5.5.3 Data Caching 263
5.6 Graphic Data Generation and Presentation 269
5.7 Discussions 273
5.8 Exercises and Projects 274
Chapter 6 Dependability of Service-Oriented Software 280
6.1 Basic Concepts 280
6.1.1 Dependability 280
6.1.2 Dependability Attributes and Quality of Service 281
6.1.3 Security Issues in SOA Software 282
6.2 Security Design in Web Applications 284
6.2.1 IIS and Windows-Based Security Mechanisms 284
6.2.2 Forms-Based Security 286
6.2.3 Applying Secure Sockets Layer 292
6.3 Dependable Computing in Windows Communication Foundation 293
6.3.1 WS-Security 293
6.3.2 WS-Reliability 295
6.3.3 Transactions 297
6.4 Discussions 299
6.5 Exercises and Projects 300

Part II Advanced Service-Oriented Computing and Large System Composition

Chapter 7 Service-Oriented and Resource-Oriented Computing 306
7.1 Introduction to Windows Communication Foundation 306
7.2 Developing WCF Services Using Template 309
7.3 Developing Self-Hosting WCF Services 313
7.4 Developing a Command Line Client to Consume WCF Services 317
7.5 Developing ASP .Net GUI Client to Consume WCF Services 322
7.6 RESTful Services 324
7.6.1 Concept of RESTful Services 325
7.6.2 Converting a SOAP Service to a RESTful Service 328
7.6.3 Consuming a RESTful Service 330
7.7 Discussions 330
7.8 Exercises and Projects 330
Chapter 8 Service-Oriented Software Development by Composition 334
8.1 Overview of Composition Languages 334
8.2 BPEL 337
8.2.1 BPEL Activities and Constructs 337
8.1.2 BPEL Process 338
8.1.3 WSDL Interface Definition of BPEL Process 341
8.1.4 BPEL Process 343
8.1.5 An Example Invoking Real Web Services 346
8.2 Stateless versus Stateful Web Services 353
8.2.1 BizTalk’s Singleton Object Approach 353
8.2.2 BPEL’s Correlation Approach 354
8.3 Frameworks Supporting BPEL Composition 357
8.3.1 Oracle SOA Suite 357
8.3.2 ActiveBPEL 359
8.3.3 BizTalk 360
8.4 Mashup for Web Application Composition 361
8.5 Other Composition Languages 364
8.5.1 OWL-S 364
8.5.2 SCA/SDO 365
8.5.3 Workflow Foundation and Silverlight 367
8.5.4 WSFL: Web Services Flow Language 368
8.6 Discussions 371
8.7 Exercises and Projects 373
Chapter 9 Service-Oriented Computing in Robotics Applications 378
9.1 Service-Oriented Robotics Computing 378
9.2 Event-Driven Robotics Applications 380
9.3 Robot as a Service in Cloud Computing 383
9.4 Robotic Studio and Visual Programming Language 385
9.5 Simulating an ALU Using VPL 390
9.5.1 Logic Design of an Arithmetic and Logic Unit 391
9.5.2 Creating VPL Activities 391
9.5.3 VPL Diagram and Testing 393
9.6 Finite State Machine and VPL Diagram 396
9.7 Developing Service-Oriented Robotics Applications 398
9.7.1 Service Repository in Robotics Developer Studio 399
9.7.2 Sensor Service 399
9.7.3 Maze Navigation Algorithms 400
9.7.4 Implementing a Maze Navigation Algorithm in VPL 401
9.8 Mapping VPL to Other Platforms 409
9.9 Discussions 412
9.10 Exercises and Projects 413
Chapter 10 Interfacing Service-Oriented Software with Database 417
10.1 Databases in Service-Oriented Software 417
10.2 Relational Databases in Service-Oriented Software 419
10.2.1 Interface between Database and Software 419
10.2.2 SQL Database in ADO .Net 421
10.2.3 DataAdapter and DataSet in ADO .Net 427
10.3 XML-Based Database and Query Language XQuery 430
10.3.1 Expressing Queries 431
10.3.2 Transforming XML Document 433
10.3.3 XQuery Discussions 434
10.4 LINQ, Language Integrated Query 435
10.4.1 What is the Purpose of LINQ? 435
10.4.2 Lambda Expressions 435
10.4.3 LINQ to Object 438
10.4.4 LINQ to SQL 439
10.4.5 LINQ to XML 443
10.5 Exercises and Projects 445
Chapter 11 Ontology and Semantic Web 449
11.1 Semantic Web and Ontology 449
11.2 Ontology Languages RDF 450
11.3 RDF Schema 452
11.4 Reasoning and Verification in Ontology 459
11.5 OWL: Web Ontology Language 460
11.5.1 From RDF to OWL 460
11.5.2 The OWL Class and Property 461
11.5.3 Boolean Combinations of Classes 462
11.5.4 Property Restrictions 462
11.5.5 Synopsis of OWL Lite, DL, and Full 464
11.6 Ontology Development Environments 465
11.7 Discussions 466
11.8 Exercises and Projects 468
Chapter 12 Service-Oriented Application Architecture 471
12.1 Introduction 471
12.2 Application Architectures 473
12.2.1 Dynamic Architecture via Dynamic Composition 475
12.2.2 Dynamic Re-Composition 476
12.2.3 Lifecycle Management Embedded in Operation Infrastructure 477
12.3 Examples of Service-Oriented Application Architectures 479
12.3.1 IBM WebSphere Architecture 479
12.3.2 Enterprise Service Bus 481
12.3.3 FERA Community Project 482
12.3.4 SAP NetWeaver 483
12.3.6 Service-Oriented Enterprise Model 484
12.3.7 User-Centric Service Oriented Architecture 486
12.4 Discussions 487
12.5 Exercises and Projects 489
Chapter 13 A Mini Walkthrough of Service-Oriented Software Development 494
13.1 Introduction 494
13.2 Sample Domain Model 498
13.2.1 Ontology Systems 499
13.2.2 Published Services 503
13.2.3 Published Workflows 506
13.2.4 Shipping Domain Collaboration Templates 508
13.3 Specific Requirements for a Project 509
13.4 A Worked Example 512
13.5 Discussions 521
13.6 Exercises and Projects 523
Chapter 14 Cloud Computing and Software as a Service (SaaS) 525
14.1 Introduction 525
14.2 SaaS Maturity Model 528
14.3 Database Design for Multi-tenancy SaaS 532
14.3.1 Resource Isolation Patterns 534
14.3.2 Security 537
14.3.3 Scalability 539
14.4 Google App Engine (GAE) 540
14.4.1 Services 541
14.4.2 Datastore 542
14.4.3 Best Practices for Developing Scalable Applications 543
14.4.4 Development and Tooling 543
14.4.5 Other Constraints 543
14.5 Google File System (GFS) 544
14.5.1 GFS System Structure and Operations 544
14.5.2 Lessons Learned from Developing GFS 546
14.5.3 Other Similar Projects 546
14.6 BigTable 547
14.6.1 Major Components 548
14.6.2 BigTable Overview 548
14.7 MapReduce 555
14.7.1 MapReduce Programming Model 555
14.7.2 Example 555
14.7.3 Types 556
14.7.4 Execution Overview 556
14.7.5 Task Granularity 557
14.8 Hadoop 557
14.8.1 Hadoop Ecosystem 557
14.8.2 Hadoop HDFS & MapReduce 558
14.8.3 Example 559
14.9 Microsoft Azure 561
14.9.2 Azure Architecture 561
14.9.3 Azure Elements 562
14.9.4 Azure Cloud Applications 564
14.10 Saleforce.com 564
14.11 Prioritization and Scheduling 571
14.12 Cloud Computing Algorithms 578
14.13 Applications of Data Differencer 590
14.14 Discussions 591
14.15 Exercises and Projects 592

Part III Appendix: Tutorials on Component-Based and Service-Oriented Software Development

Appendix A Component-Based Movie and Game Programming 602
A.1 Developing a Game in an Engineering Process 602
A.2 Basic Programming Concepts in Alice 603
A.3 Graphic Programming 606
A.4 Online Tutorials and Examples 607
Apendix B Web Application Development 609
B.1 Design of Graphical User Interface 609
B.2 Discovering Web Services Available Online 615
B.3 Access Web Services in Your Program: Cinema Service 617
B.4 Access Web services in Your Program: Weather Forecasting Service 622
B.5 Access Web Services in Your Program: USZip Service 625
Appendix C Service-Oriented Robotics Applications 627
C.1 Getting Started with Microsoft Robotics Studio and VPL Programming 627
C.2 Programming Conditions in VPL 629
C.3 Programming Loop in VPL 630
C.4 Programming a Robot in a Simulation Environment 631
C.5 Deploying the Program to a Real Robot 638
C.6 Programming the Arm of the Robot 639
C.7 Autonomous Robot in an Obstacle Course 641
C.8 Autonomous Robot Exploring a Maze 647
Appendix Exercises and Projects 655
References 659
Index 663