Welcome!

Microservices Expo Authors: Elizabeth White, Karthick Viswanathan, Cameron Van Orman, Jason Bloomberg, Pat Romanski

Related Topics: Microservices Expo

Microservices Expo: Article

Horses for Courses: Services, Objects, and Loose Coupling - Integration without compromise

Horses for Courses: Services, Objects, and Loose Coupling - Integration without compromise

Object-oriented technologies are used today in the design and development processes for many computer systems; it is a proven paradigm and has made possible the development of large and complex software systems. Enabling platforms and tools for building and consuming Web services will not be an exception. However, how a service is implemented using objects and the way in which it interacts with other services via message exchanges require very different approaches.

Today, most tools represent Web services to application developers as objects. Such an approach carries the danger of underperformance and fragile applications with too tight a level of coupling, which loses the benefits of service orientation. This article shows you how objects and services should be integrated to build loosely coupled, performant, and reusable services without compromising either paradigm.

Anatomy of a Web Service
To frame this discussion, we must first reach a common understanding of what exactly a Web service is. Our deliberately simple view of a service is as an entity that exchanges messages (usually with other services), with well-defined boundaries. A Web service shares those characteristics, but adds the constraint that the messages exchanged between Web services are in fact SOAP messages carried over some suitable transport protocol (which may include application protocols like HTTP).

Those messages may contain out-of-band data for quality-of-service purposes, and are produced and consumed by a piece of middleware, usually called a SOAP server, SOAP stack, or SOAP message processor. It is this middleware that performs the translation of SOAP messages into a form more suitable for processing at the application level, which it typically does by converting the SOAP XML message into application objects. This canonical Web service is shown in Figure 1, and will form the basis for later discussion on how objects and services interact. Please note that Figure 1 is only a conceptual view of a canonical Web service and there is no suggestion of a one-to-one association between a Web service and a particular host. Indeed, an entire infrastructure with computational, data, human, etc., resources could make a single Web service.

An Object-Oriented System
Before we explore the interaction between objects and services, it is useful to recall how we would implement a purely object-based system. Consider a simple purchase-order system that is used by a (potentially remote) purchase-order application, composed from a number of purchase-order objects.

In Figure 2, we see that the purchasing application holds a reference to (potentially remote) purchase order objects. Through those references, the application can obtain information about the purchase order, such as the order number, the date, the cost of the order, and the items requested.

While this approach is appealing because of its simplicity, it suffers from a number of drawbacks if we try to scale it to Internet-level computing. First, while the interface of the purchase order object is defined at the right level for a closed system (either a stand-alone application or an intranet-based distributed object environment), it is far too fine grained to use efficiently over a wide area network. The network overhead of calling a method like getPurchase OrderNo() outside of a single domain is prohibitively high.

Second, we see that the level of coupling with this approach is very high. If, for example, the purchasing application and the purchase order object physically belong in separate organizations (which is the normal case in CORBA, where object references are propagated around an application and the underlying infrastructure handles location transparency), then the organization hosting the purchase order object can legitimately delete that object but, as a consequence, breaks the other organization's purchasing application, which relied on a reference to that object. Of course, technologies for maintaining referential integrity have been devised (e.g., distributed reference counting and garbage collection, leasing, etc.), but in most cases they don't scale very well either.

Finally, and most crucially, this approach assumes that there is a type system shared by the purchasing application and the purchase order object. If two application domains are unable to share a type system, for instance if one is built on .NET and the other on J2EE, then direct invocation of objects from one domain into the other is all but precluded, which means that specialist adapters then have to be deployed to solve the problem piecemeal.

While middleware like CORBA or DCOM can hide the differences between individual language and platform technologies and allow, for example, a C++ purchasing application to invoke a Java purchase order object, it does so because it uses its own metalevel type system, and does not solve the problem of sharing types but moves it to the metalevel. It also throws up the barrier that if there is no IDL mapping to the language that a specific component is written in, then there is no way that component can be used in the application.

Don Box of Microsoft sums this up very neatly when he notes that "shared abstractions are expensive." Box convincingly argues that for a distributed object approach to have a hope of working across enterprise boundaries, all parties involved in the construction of the application have to agree on the set of shared abstractions. As the number of parties involved increases, there is a combined explosion of different systems, different people, and different corporate politics to navigate, and eventually the rewards for deploying such a system are outweighed simply by the effort required to deploy it.

An Object-like System Using SOAP and WSDL
If there are problems in scaling object-based systems, it seems an attractive idea to use technologies like SOAP and WSDL to alleviate that problem. One such common approach is shown in Figure 3.

The example shown in Figure 3 at first appears to solve the issues that we previously identified with integrating multiple enterprises' object-based systems. Certainly, it seems to solve the problem about having shared types, since now all type information is exposed via a WSDL interface that allows any software agent that understands the WSDL to invoke the object behind the service. It also means that specialist adapters can be replaced with commodity SOAP stacks in order to plumb various application components together. The ability to understand XML, XML Schema, and SOAP are the only assumptions being shared.

However, there are significant flaws in this approach. While this approach may be platform neutral because of the XML payloads that we move across the network, applications built this way may not be performant because we have exposed the same fine-grained object interface for consumption, and we still have to bear the cost of translating to and from XML whenever we want to invoke such a method.

Worse, applications built this way are brittle. For example, imagine that the purchase order object is made available at the URL http://example.com/wsj/purchaseOrder/14529 and that the client binds to that URL and begins to invoke methods (via SOAP) on the purchase order object. Given that the purchase order object is a resource that belongs to an enterprise, that enterprise is perfectly within its rights to manage that resource as it sees fit, including to move or delete it. If the URL of the purchase order object changes or disappears, this has the knock-on effect of breaking the purchasing application.

While we have schemes such as that used in OGSI, which address this brittleness by providing a mechanism to re-resolve an endpoint in case a resource is moved, this patch fails to address the fundamental problem with this approach - that an enterprise's private resources (objects) are being exposed to the network. In short, this approach is nothing more than CORBA or DCOM with angle brackets, and while CORBA and DCOM were extremely useful technologies in their specific domain, in this context such an architecture is, at best, ungainly.

Given these drawbacks, we must ask what would drive developers and architects to propose such solutions. While one motivation is the (completely inaccurate) view that Web services are a yet another distributed object system, we feel the primary reason for this model having permeated so far into the developer mindset is tool support.

For instance, the WebMethod attribute in .NET makes it easy to expose an object as a Web service, even though such objects may well have fine-grained interfaces that are wholly unsuitable for exposure as a Web service. On the client side, tools like Axis WSDL2Java present the abstraction of a Web service as an object with methods (which is ironic given that at least some of the time it, lamentably, is).

A Service-Oriented View
So far we have seen the pitfalls of mixing service and object orientation. However, both are extremely valuable techniques and in order to derive maximum benefit from them we simply need to understand where it is best to utilize each, and how the object-service interface should look. To put things into perspective, let's revisit the purchase order system from a service-oriented architecture point of view.

The diagram shown in Figure 4 fixes all of the problems we encountered in examining previous approaches. There is much looser coupling in this system since no back-end resources are exposed across administrative boundaries. Instead, a (logically, though not necessarily physically) single, fixed endpoint is used as the entry point to a process that deals with the creation of a purchase order. When that process is invoked, some business-specific activity is executed and a purchase order document is passed back to the purchasing application. The purchase order service interface is now much more coarse grained as it captures an entire business process rather than individual method calls, and is likely to be performant and scalable.

However, this is only half the story as far as we are concerned. While this architecture is the correct choice for this application, we still need to see how it can be mapped into code in the service implementation. Figure 5 presents the details of the implementation of the purchasing order service and shows in greater detail how a service could be implemented using objects without actually exposing them.

The fundamental issue shown in Figure 5 is that it is the messages exchanged with Web services that should be consumed by applications, and not the Web services themselves. Where Web services are seen as application-level objects, there is the constant danger we'll fall into the trap of treating them as objects.

However, with this approach we use fewer but richer message exchanges, we increase the granularity of a Web service, and reduce the performance penalty. This strategy also ensures that loose coupling is the norm since applications never bind directly to services, only to messages. Since those messages can come from any source as far as the application is concerned, migrating the service provider to another service is not invasive to the application. Finally, since the architecture is concerned only with messages and message exchanges, the barrier to entry for any enterprise is low. There is no need to argue about whether a system should be based on J2EE, .NET, or some other technology since most platforms have Web services support nowadays.

Conclusion
Building object-like systems on top of Web services specifications is a strategy that leads to tightly coupled, brittle, and underperforming systems. While the current crop of tool support implicitly advocates this approach to the unwary, a far better solution is to think of an application in terms of services and the messages that those services exchange. When building code for those service implementations don't be tempted to bind directly to a Web service, but instead bind to the messages that the service produces and consumes. Such an approach promotes loose coupling; your applications will be able to transcend changes in the service they consume and will be much easier to maintain.

References

  • Box, Don. (2003). "Service-Oriented Architecture and Programming (SOAP), Parts 1 and 2." Talks from the MSDN TV archive (Part 1, Part 2).
  • Tuecke, Steve., et al. (2003) "Open Grid Services Infrastructure (OGSI) - Version 1.0". https://forge.gridforum.org/projects/ogsi-wg.
  • More Stories By Jim Webber

    Dr. Jim Webber is a senior researcher from the University of Newcastle
    upon Tyne, currently working in the convergence of Web Services and Grid
    technologies at the University of Sydney, Australia. Jim was previously
    Web Services architect with Arjuna Technologies where he worked on Web
    Services transactioning technology, including being one of the original
    authors of the WS-CAF specification. Prior to Arjuna, Jim was the lead
    developer with Hewlett-Packard on the industry's first Web Services
    Transaction solution. Co-author of "Developing Enterprise Web Services -
    An Architect's Guide," Jim is an active speaker and author in the Web
    Services space. Jim's home on the web is http://jim.webber.name

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @MicroservicesExpo Stories
    Is advanced scheduling in Kubernetes achievable? Yes, however, how do you properly accommodate every real-life scenario that a Kubernetes user might encounter? How do you leverage advanced scheduling techniques to shape and describe each scenario in easy-to-use rules and configurations? In his session at @DevOpsSummit at 21st Cloud Expo, Oleg Chunikhin, CTO at Kublr, will answer these questions and demonstrate techniques for implementing advanced scheduling. For example, using spot instances ...
    These days, APIs have become an integral part of the digital transformation journey for all enterprises. Every digital innovation story is connected to APIs . But have you ever pondered over to know what are the source of these APIs? Let me explain - APIs sources can be varied, internal or external, solving different purposes, but mostly categorized into the following two categories. Data lakes is a term used to represent disconnected but relevant data that are used by various business units wit...
    DevSecOps – a trend around transformation in process, people and technology – is about breaking down silos and waste along the software development lifecycle and using agile methodologies, automation and insights to help get apps to market faster. This leads to higher quality apps, greater trust in organizations, less organizational friction, and ultimately a five-star customer experience. These apps are the new competitive currency in this digital economy and they’re powered by data. Without ...
    Today most companies are adopting or evaluating container technology - Docker in particular - to speed up application deployment, drive down cost, ease management and make application delivery more flexible overall. As with most new architectures, this dream takes significant work to become a reality. Even when you do get your application componentized enough and packaged properly, there are still challenges for DevOps teams to making the shift to continuous delivery and achieving that reducti...
    With the modern notion of digital transformation, enterprises are chipping away at the fundamental organizational and operational structures that have been with us since the nineteenth century or earlier. One remarkable casualty: the business process. Business processes have become so ingrained in how we envision large organizations operating and the roles people play within them that relegating them to the scrap heap is almost unimaginable, and unquestionably transformative. In the Digital ...
    With the rise of DevOps, containers are at the brink of becoming a pervasive technology in Enterprise IT to accelerate application delivery for the business. When it comes to adopting containers in the enterprise, security is the highest adoption barrier. Is your organization ready to address the security risks with containers for your DevOps environment? In his session at @DevOpsSummit at 21st Cloud Expo, Chris Van Tuin, Chief Technologist, NA West at Red Hat, will discuss: The top security r...
    The nature of the technology business is forward-thinking. It focuses on the future and what’s coming next. Innovations and creativity in our world of software development strive to improve the status quo and increase customer satisfaction through speed and increased connectivity. Yet, while it's exciting to see enterprises embrace new ways of thinking and advance their processes with cutting edge technology, it rarely happens rapidly or even simultaneously across all industries.
    Most of the time there is a lot of work involved to move to the cloud, and most of that isn't really related to AWS or Azure or Google Cloud. Before we talk about public cloud vendors and DevOps tools, there are usually several technical and non-technical challenges that are connected to it and that every company needs to solve to move to the cloud. In his session at 21st Cloud Expo, Stefano Bellasio, CEO and founder of Cloud Academy Inc., will discuss what the tools, disciplines, and cultural...
    Enterprises are moving to the cloud faster than most of us in security expected. CIOs are going from 0 to 100 in cloud adoption and leaving security teams in the dust. Once cloud is part of an enterprise stack, it’s unclear who has responsibility for the protection of applications, services, and data. When cloud breaches occur, whether active compromise or a publicly accessible database, the blame must fall on both service providers and users. In his session at 21st Cloud Expo, Ben Johnson, C...
    21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
    ‘Trend’ is a pretty common business term, but its definition tends to vary by industry. In performance monitoring, trend, or trend shift, is a key metric that is used to indicate change. Change is inevitable. Today’s websites must frequently update and change to keep up with competition and attract new users, but such changes can have a negative impact on the user experience if not managed properly. The dynamic nature of the Internet makes it necessary to constantly monitor different metrics. O...
    Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
    Many organizations are now looking to DevOps maturity models to gauge their DevOps adoption and compare their maturity to their peers. However, as enterprise organizations rush to adopt DevOps, moving past experimentation to embrace it at scale, they are in danger of falling into the trap that they have fallen into time and time again. Unfortunately, we've seen this movie before, and we know how it ends: badly.
    There is a huge demand for responsive, real-time mobile and web experiences, but current architectural patterns do not easily accommodate applications that respond to events in real time. Common solutions using message queues or HTTP long-polling quickly lead to resiliency, scalability and development velocity challenges. In his session at 21st Cloud Expo, Ryland Degnan, a Senior Software Engineer on the Netflix Edge Platform team, will discuss how by leveraging a reactive stream-based protocol,...
    Many organizations adopt DevOps to reduce cycle times and deliver software faster; some take on DevOps to drive higher quality and better end-user experience; others look to DevOps for a clearer line-of-sight to customers to drive better business impacts. In truth, these three foundations go together. In this power panel at @DevOpsSummit 21st Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, industry experts will discuss how leading organizations build application success from all...
    The last two years has seen discussions about cloud computing evolve from the public / private / hybrid split to the reality that most enterprises will be creating a complex, multi-cloud strategy. Companies are wary of committing all of their resources to a single cloud, and instead are choosing to spread the risk – and the benefits – of cloud computing across multiple providers and internal infrastructures, as they follow their business needs. Will this approach be successful? How large is the ...
    You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
    "NetApp's vision is how we help organizations manage data - delivering the right data in the right place, in the right time, to the people who need it, and doing it agnostic to what the platform is," explained Josh Atwell, Developer Advocate for NetApp, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
    The “Digital Era” is forcing us to engage with new methods to build, operate and maintain applications. This transformation also implies an evolution to more and more intelligent applications to better engage with the customers, while creating significant market differentiators. In both cases, the cloud has become a key enabler to embrace this digital revolution. So, moving to the cloud is no longer the question; the new questions are HOW and WHEN. To make this equation even more complex, most ...
    One of the biggest challenges with adopting a DevOps mentality is: new applications are easily adapted to cloud-native, microservice-based, or containerized architectures - they can be built for them - but old applications need complex refactoring. On the other hand, these new technologies can require relearning or adapting new, oftentimes more complex, methodologies and tools to be ready for production. In his general session at @DevOpsSummit at 20th Cloud Expo, Chris Brown, Solutions Marketi...