IBM Cloud Authors: Kevin Jackson, Pat Romanski, Liz McMillan, Yeshim Deniz, Carmen Gonzalez

Related Topics: IBM Cloud

IBM Cloud: Article

Developing Web Services with WebSphere Studio

Developing Web Services with WebSphere Studio

So you've heard all about how great Web services are and how they are revolutionizing the way distributed systems are being developed. You've read all about how this new set of standards is changing the Enterprise Application Integration (EAI) space and how it's finally making interoperability possible. You've even heard that it's possible to make calls on code written in C# and deployed using ASP.NET and have read an article or two about SOAP, WSDL, and UDDI. It's time to take the next step.

This month I thought it fitting to cater to those of you ready to take the plunge and try your hand at developing a Web service or a Web service client. Incidentally, if you still haven't done all the recommended reading, don't sweat it - you really don't have to know too much when using WebSphere Studio. Also, this article will try to bring you up to speed, but just a bit though - wouldn't want to bore the folks who've already read it all.

If you're reading this magazine, chances are you're using the IBM WebSphere family of products. This means you're using the WebSphere Application Server as your deployment environment and some combination of WebSphere Studio and/or VisualAge for Java as your development environment. Web services are fairly new on the technology map and thus also on the WebSphere product roadmap. Web services were first supported by the Web Services Toolkit, which was introduced on alphaWorks. More importantly, as of version 4, Web services are directly supported by the WebSphere Application Server (WAS) as well as the WebSphere Studio development tools. This two-part article explains how to create and use Web services using the new WebSphere Studio product line, specifically using WebSphere Studio Application Developer (WSAD).

This month I'll focus on the use of WSAD to develop and publish a Web service. You'll see how to use the Web services wizard to wrap an existing Java method as a Web service and expose the metadata required for invoking the service. You'll then see how to use another tool - the UDDI Explorer - to publish your service on a public registry so others can find and use it. Next month I'll focus on building a client that invokes the Web service and on running a sample test application.

The WebSphere Studio Product Family
Starting with version 4, a new set of development tools has been introduced as part of the WebSphere Studio product family. IBM now offers two new tools - WebSphere Studio Site Developer (WSSD) and WebSphere Studio Application Developer (WSAD). Those of you who have been using WebSphere Studio in one of its previous incarnations or who have been using VisualAge for Java will be pleasantly surprised. Both of these new tools are much better in terms of the developer's experience and in terms of the tools available to save time.

WSSD targets Web developers who are focused more on the Web application than on underlying server code. WSAD is a more complete environment that supports Web developers but provides more focus on J2EE developers. Both environments allow you to develop Java code and both tools support the development of Web services in a similar way, but if you are a hardcore developer, chances are that you will be using WSAD. In any case, both tools share a common development metaphor and both support the development of Web services in a similar way. The examples in this article use WSAD, but they are also relevant to those of you who prefer using WSSD (which is overall a simpler tool to use).

Application Developer (as well as Site Developer) is based on the concept of a developer role and implements a set of perspectives. A perspective is an organization of the workbench that focuses on a developer role and presents the "best-practice" layout of the tools most often used in that developer role. For example, the Web perspective focuses on the set of tools for editing JSPs, scripts, servlets, etc. The Server perspective includes the server configuration pane for the WebSphere test environment, the test environment console, and a set of tools used for configuring the test environment. You can open many perspectives and easily switch between them when you go through the code-test-debug-package cycle.

You use WSAD for all development tasks. Whether you mostly develop JSP, EJB, core Java code, or Web services, WSAD is the tool you consistently use. One of the implications is that VisualAge for Java is being phased out and WSAD is replacing it. Don't be sad - WSAD is superior in every aspect and you'll find it very easy to use. IBM has done a nice job in packaging all these tools together in a way that makes it powerful and usable at the same time. (Just for the record - I don't work for IBM and [unfortunately for me] I'm not getting paid by IBM to say these things.)

Web Services and WSAD
Without going into any of the (very interesting) details, a Web service is a method that is deployed on an application server and invoked over the Web. Web services are usually used by other applications and systems and are becoming the preferred way to integrate and interoperate in environments that involve decoupled, distributed applications.

What makes a method deployed on an application server a Web ser-vice is not the "what" but the "how." A Web service invocation is done using the Simple Object Access Protocol (SOAP). SOAP is an XML-based protocol that packages the arguments needed to invoke the service along with the invocation details, routing details, and more. The SOAP message usually travels over HTTP, but other underlying protocols may also be used. SOAP is a de facto standard. It is backed by the entire software industry, including IBM and Microsoft. This is what makes Web services so special and so powerful. It means that there is finally an agreed-upon way to communicate between different platforms; let's just hope it stays this way and that no one thinks of "extending" it (after having "embraced" it).

There are two more standards involved with Web services - the Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI). WSDL defines how to describe a Web service. After all, if you develop a ser-vice for others to use you need to be able to tell them how to invoke the service. WSDL documents the metadata with which a client application learns how to invoke the ser-vice and describes things such as where the service is deployed, what arguments to pass in, and what the return value will look like. Once you have this document you need to publish your service to a UDDI registry using the UDDI APIs available from such registries. Sometime later, client applications make UDDI calls to search for a service based on some criteria, discover your service, get the WSDL description, and start using your service.

SOAP, WSDL, and the UDDI APIs are standards and are therefore well-documented. They are all based on XML and it's therefore possible for a human to read and write such documents. You can (theoretically) write SOAP messages and WSDL descriptions using your favorite text editor.

If you've had much experience with XML you already know that XML documents tend to be verbose. Because SOAP, WSDL, and UDDI offer comprehensive support for distributed invocations, these XML documents tend to quite quickly become complex and difficult to write. Therefore, you should not be writing these XML documents yourself. Instead, you should be using tools - specifically WSAD.

WSAD hides the complexity of the mechanics of Web services behind a set of tools and wizards. You can do all your Web services development quickly and efficiently without writing a single line of XML. You can also publish Web services on a registry using a WSAD tool. It's time to move on and see some of the magic.

Developing the Web Service
Assume you're building a Web service that uses advanced optimization algorithms to create efficient driving patterns. People who need to visit a set of locations during a work day access your service and tell you where they need to go. You in turn have a smart routing and optimization engine and access to historical traffic patterns with which you can suggest an optimal sequence that the person should visit in order to minimize driving time. Your service can be used by applications used by delivery drivers, service technicians, claims adjustors, and more.

Assume that you already have the Java code that performs this optimization (maybe you already implemented this for your company and now want to create a new revenue stream by selling the service to other companies). In order to simplify things, assume you have a class called WorkOrderSequencer that has a method with the following signature:

public int[]
lats, long[] longs)


As input you receive two arrays with the latitude and longitude coordinates for the places that the employee needs to visit. Your reply is an array with the sequence order. For example, if you are passed 10 locations, you may return an array of the form {4,6,2,3,1,8,9,7,0,5} meaning that the person should first visit the location with the fourth latitude/longitude, then the location with the sixth latitude/longitude, and so on.

Having the method implemented is just the beginning - what you really want to do is develop the Web service - the wrapper through which your method can be called from another system. You use WSAD's Web services wizard in order to do that. The wizard guides you through a set of simple steps and at the end "wraps" your method with a Web service and generates all the files needed for you to deploy the Web service (along with the implementing code) on a WebSphere Application Server. Obviously, the WAS instance needs to be enabled for Web services - as is WAS version 4.

As an example, Figure 1 shows the wizard panel in which you specify which class to wrap, Figure 2 shows the wizard panel in which you specify where the service is located and where the metadata and WSDL files should be stored, and Figure 3 shows the wizard panel in which you select which methods to wrap as Web ser-vices and what type of XML encoding should be used for marshaling arguments.

When you complete filling in all your preferences, the wizard goes to work. It generates all the needed metadata files for the SOAP invocation to be handled correctly. It also generates all that is required for making a Web service invocation - but that's part of next month's column.

Let's look at the metadata that the tool generates on your behalf, i.e., all the hard work it saves you. The first thing that the wizard generates is an XML Schema Definition (XSD). The XSD describes the types used within the Web service. Listing 1 shows the XSD generated based on the method's signature. It defines complex types for an array of int and an array of long as extensions to the SOAP array type.

Next is the service description defined by the WorkOrderSequencer-Service.wsdl shown in Listing 2 (some of the details are omitted for the sake of brevity). This WSDL file defines the location of the service using a SOAP address that's embedded in a port definition. The SOAP address - the most important element - specifies how client applications invoke the service. The address always points to a fixed servlet, the rpcrouter. This is part of the Web services infrastructure packaged within WAS version 4. This servlet receives requests and maps the ser-vice request to the implementing class - the class and method you are wrapping as a Web service.

The service WSDL file imports the binding WSDL file. The binding WSDL (shown in Listing 3) includes a definition for the remote interface, a definition for all possible messages (both requests and responses, because SOAP is inherently asynchronous), and the operation definitions along with the encoding properties. Clearly, I've glossed over the gory details because they could fill tens of pages. That's the beauty of WSAD - you don't need to know any gory details in order to develop Web services!

Publishing the Service
Once you finish developing a Web service you usually proceed to test it and debug it. Then you package your application as an EAR (that has a WAR) and install it on your WAS instance. Once you complete all these steps you have a Web service deployed on the Web. The only problem is that no one knows about it.

That's what registries are for. Specifically, UDDI registries allow you to publish your Web services for other applications to discover and use. They allow you to define a business (with a set of descriptive parameters) and the Web services provided by this business.

There are two kinds of UDDI registries - public and private registries. Private registries are registries that you implement yourself within an organizational boundary. For example, you might want to implement an interdepartmental registry as part of your enterprise architecture. Such registries aren't normally open to the general public. Public registries, on the other hand, are open for anyone to use. As an example, IBM implements a public registry called the IBM UDDI Business Test Registry. You can register as a user at https://www-3.ibm.com/services/uddi/ testregistry/protect/registry.html, after which you can publish and discover services using this public registry.

UDDI registries are accessed using a set of Web services (what else?). In order to publish a service on a UDDI registry, you issue a SOAP message using one of the UDDI APIs. Once more, WSAD saves you the hassle by providing a tool - the UDDI Explorer. This tool allows you to define all of the properties and then creates the SOAP messages on your behalf.

The UDDI Explorer is used to publish your business and Web services and also used to discover services - but you'll have to wait until next month to learn about that. When publishing your business you specify its name, phone number, e-mail address, and other contact information. You also classify your business using the United Nations Standard Products and Services Classification (UNSPSC), the North American Industrial Classification System (NAICS), or a geographic classification (e.g., country and state). These classification schemes help someone looking for a certain type of business to find you - similar to the way yellow pages are used. For example, Figure 4 shows some possible UNSPC categories you could choose from in order to classify your business.

After publishing your business, go ahead and publish the Web service. You can again classify the service using categories from any of the mentioned classification schemes. In addition to that you specify the URL for the WSDL file describing your Web service. A service consumer using the UDDI registry will find your service while doing a search for one of the categories and then will use the WSDL to learn where the service is deployed and how to invoke it.

Web services are among the newest, greatest (and certainly most hyped) technologies to hit the e-business landscape recently. It isn't surprising therefore that the latest versions of both WAS and WebSphere Studio provide support for Web services. This month's article described the support provided by WebSphere Studio Application Developer for developing and publishing Web services. This is only half of the story - WSAD also supports discovering Web services and building client applications that make use of these services, which is the topic of next month's installment.

More Stories By Ron Ben-Natan

Ron Ben-Natan is Chief Technology Officer at ViryaNet Inc. Prior to that he worked for companies such as Intel, AT&T Bell Laboratories, Merrill Lynch and as a consultant at J.P. Morgan. He has a Ph.D. in Computer Science in the field of distributed computing and has been architecting and developing distributed applications for over 15 years. His hobby is writing about how technology is used to solve real problems and he has authored numerous books including “IBM WebSphere Application Server: The Complete Reference” published by Osborne/McGraw. He can be reached at

More Stories By Doron Sherman

Doron Sherman is the CTO of Collaxa, Inc., a Web Service Orchestration Server vendor and a BEA Partner located in Redwood Shores, California. He has been involved with Java since its early days and pioneered application server technology while being a founder and chief scientist at NetDynamics.

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.

@ThingsExpo Stories
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo 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 ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo 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 ...