Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Using Real-World Commercial Web Services In BEA Platform 7.0

Using Real-World Commercial Web Services In BEA Platform 7.0

Web services are, among other things, a steamy bowl of alphabet soup. When developers set out to explore this new area of software development, they are immediately confronted with a number of new terms such as SOAP, WSDL, UDDI, JAX-RPC, and more. While these terms can initially seem confusing and potentially intimidating, most experienced developers are surprised to learn how easy it actually is to begin developing with Web services. Developers are often pleasantly surprised to discover how little of these "inner workings" one need know before getting started as an effective Web services developer. This is especially true with the improved support for Web services in BEA WebLogic Platform version 7.0.

When talking about Web services, there are principally two roles: the client and the server. The "client" uses the Web service while the "server" provides the Web service for use by various clients within the enterprise and beyond. This article focuses exclusively on the client side of Web services and does so through a real-world example. This example is the validation of U.S. geographical addresses via a commercially available Web service.

Nearly all enterprise business systems manage and process geographical address data. Examples include customer addresses, billing addresses, shipping addresses, delivery addresses, and more. The relevant business question is, what is the business benefit of ensuring these addresses are correct? Will correct addresses reduce shipping costs? Will correct addresses also reduce delivery costs? Furthermore, will they reduce other costs associated with redundant addresses? In 2003, one should ask oneself, with the availability of address validating Web services, why should any of the business-critical addresses of a large corporation be at risk of being incorrect?

One example of the small number of commercial addresses validating Web services available today is DOTS for Address Validation provided by ServiceObjects. ServiceObjects, an early innovator of Web services, provides this Web service as well as a number of similar utility Web services. Examples include stock quotes and company information, weather information, IP address-to-location determination, nearest ATM location identification, reverse telephone number lookup, yellow pages, e-mail address validation, shipping comparisons, package tracking, and more. The example presented will focus solely on address validation.

Identifying and Understanding the Web Service
The first step in using a Web service is identifying the Web service to use. The most important item to obtain is a reference to the Web Services Definition Language (WSDL) file. The WSDL file describes the interface, or the functional capabilities, of the Web service. In the DOTS for Address Validation example, the WSDL is located at:


For input, this Web service takes a formatted input address and a license key through a number of parameters. Although an individual Web service can support multiple methods, this example has only one method, ValidateAddress(). Each Web service method has a number of arguments. In the ValidateAddress() example, the method takes five parameters, each of type String. These include address, city, state, postalCode, and licenseKey. An example input address is that of the author's employer, eFORCE, with corporate headquarters located at 4120 Point Eden Way, Hayward, CA, 94545. In addition to the input address, a license key is required. For this specific Web service the value "0" designates a trial license key which can be used for testing purposes. This example illustrates one way vendors are accommodating licensing of Web services as standards evolve.

For output, the Web service returns a response. In the illustrated example the response may contain an Address comprised of the fields of the validated address or an Err if any errors occurred. When passed the above address of eFORCE, the Web service responds with 4120 POINT EDEN WAY, HAYWARD, CA, 94545-3703 having validated the address and filled in the proper zip+4 value.

It is interesting to note that while WSDL is a semantic equivalent of several predecessor definition languages, such as CORBA IDL, and it is based upon XML, it is not meant for human readability. Reading and writing WSDL are best left to tools.

Setting Up the Environment
There are several different tools for building and using Web services from within BEA WebLogic Server version 7.0. This example will leverage the command-line utilities.

The first step is to set up the environment. Execute either setWLSEnv.cmd or setWLSEnv.sh depending upon your operating system. This script is located in the directory NL_HOME/server/bin where NL_HOME is the top-level directory of the WebLogic Platform installation. At this point the Web services client generation utility, clientgen, should be in the CLASSPATH. This can be confirmed with the command:

java weblogic.webservices.clientgen

This should produce usage help for clientgen.

Generating the Proxy
The easiest way to utilize a Web service is to create a static-binding proxy. To generate such a proxy for the example address validation Web service, the following command is utilized:

java Weblogic.Webservices.clientgen \-wsdl
Validate.asmx?WSDL \
-clientJar av.jar \
-packageName com.serviceobjects.www

This will produce an av.jar file that will need to be placed in the CLASSPATH.

Writing a Robust Wrapper
It is often a good practice to create wrappers for underlying third-party implementations. It is also often a good habit to test components outside the scope of the application server where possible (see Listing 1). The first class used in the wrapper is an address value object.

In this example, the value object is immutable. The immutable pattern is leveraged so the AddressFactory must be utilized by client classes to obtain an Address object.

The AddressFactory is the class utilized by client classes to obtain a valid address. Notice that this class includes a simple main() which will be used later for simple unit testing (see Listing 2).

To obtain a validated address, client classes simply call the factory method of the AddressFactory as follows:

Address address = AddressFactory.getAddress(
"4120 Point Eden Way",
"Hayward", "CA", "94545");

The AddressFactory class uses several classes in its implementation. InvalidAddressException and AddressValidationException are application exceptions used to designate a bad input address and an internal processing error respectively. In addition to these two exception classes, the AddressFactory uses an AddressValidator interface and a DOTSAddressValidator implementation of that interface.

The AddressValidator interface represents a business interface for address validation. Underlying implementations must implement the validate() method.

package com.eforceglobal.wldj.address;

interface AddressValidator {

Address validate(String address, String city, String state,
String zip) throws InvalidAddressException,


The core functionality that then ties the vendor-independent wrapper to the underlying DOTS implementation is the DOTSAddressValidator class. In this class, the implemented validate() method delegates to the previously generated proxy code using WebLogic's clientgen tool (see Listing 3).

The first initialization task that the init() method performs is setting the two system properties to instruct the JAX-RPC to use the WebLogic implementation. This initialization must be done when testing or running outside WebLogic Server and only needs to be done once - on application start-up.

The second initialization task that the init() method performs is to initialize a reference to a DOTSAddressValidate. This interface is a JAX-RPC service. The generated proxy service implementation, DOTSAddressValidate_Impl, is an implementation of javax.xml.rpc.Service. The interface is a factory and is, in many ways, analogous to the home interface in EJB client-side programming. This type of initialization only needs to be done once as this factory reference can be shared across concurrent requests.

Once these two initialization tasks have been performed, the class is ready for ongoing processing. For each client request, the validate() method performs several steps.

The first step that the validate() method performs is to create a new reference to the Web service "business" interface, here DOTSAddressValidateSoap. This step is analogous to the utilization of a home interface to obtain a reference to a remote interface in EJB client-side programming. Notice that a remote is created for each user request. This enables multiple concurrent threads in this method to share the factory but each has different implementations of the business interface.

The second step that the validate() method performs is to delegate to the generated proxy code by calling the validateAddress() method. The generated code will serialize the request from Java into SOAP, post it to the server, receive the response, and deserialize it back from SOAP into Java. Notice that the programmer did not need to delve into any details of SOAP data structures or even the JAX-RPC API.

In addition to the steps described above, the validate() method maps between underlying technology-specific exceptions to business exceptions. In providing such a wrapper, the Web tier, or GUI, client programmer does not need to know whether the AddressFactory is implemented via an EJB, Web service, database call, or other approach. This illustrates the power of encapsulation being applied to Web services.

Once the response has been obtained, it is returned to the client.

Trying It Out
To compile this class, it is necessary to have both the generated proxy described above as well as WebLogic's JAX-RPC implementation in the CLASSPATH. The generated proxy is the av.jar file created above. The JAX-RPC implementation is in webserviceclient.jar and is distributed as part of WebLogic Server version 7.0. Once these two JAR files are in the CLASSPATH, the above classes can be compiled.

The example can be tested from the command line, with the command:

java com.eforceglobal.address.wldj.AddressFactory
"4120 Point Eden Way" Hayward CA 94545

Next Steps One enhancement that could be made to the above implementation is to support "best effort" address validation. For instance, if the Web service is down, the address is not validated.

A second enhancement that is possible is to provide support for caching. The wrapper could first check a local memory cache and then call the Web service if not present in the cache. This could save money on a Web service that charges on a per-use basis as well as provide higher performance provided the data latency is acceptable. However, care would need to be taken in making sure the implementation complies with the Web service's license.

A solution that completely abstracts the ServiceObjects implementation provides "best effort" validation as well as does caching is possible in only 200 lines of code.

The sample code presented in this article as well as solutions for the two enhancements above are available from the author via e-mail.

More Information
In addition to the capabilities of ServiceObjects, there are a number of other commercial Web services providers. Amazon.com now provides access to their product catalog via Web services. Google provides limited access to their search engine. Microsoft provides maps and driving directions. You can use the techniques described in this article to integrate with those Web services from WebLogic.

In addition to the above Web services, two excellent industry sites can be used for tracking progress now being made on Web services - SalCentral and XMethods. These sites have detailed information about Web services that can easily be reviewed and tested.

Commercial Web services are now available. Some of these services, such as address validation, are useful in nearly every enterprise application.

To use these Web services, client-side Web service programming is not difficult. With the capabilities now in WebLogic, it is possible for developers to avoid many of the details of SOAP, WSDL, and JAX-RPC. Additionally, with the application of patterns such as facade, value object, immutable, factory method, cache, smart proxy, and more, it's easy to abstract other developers from robust implementations.

Web services are now here, perhaps only a few hundred lines of code away from today's enterprise applications based upon BEA WebLogic Server.


  • BEA WebLogic Server 7.0 Web Services Documentation: http://edocs.bea.com/wls/docs70/ webservices.html
  • ServiceObjects: www.serviceobjects.com
  • Amazon.com Web Services: www.amazon.com/Webservices
  • Google Web Services: www.google.com/api
  • XMethods: www.xmethods.org
  • SalCentral: www.salcentral.com
  • More Stories By Gary Meyer

    Gary Meyer is a Senior Technical Director for eFORCE where he helps Fortune 1000 clients by delivering fixed-price, fixed-time projects for enterprise portals, enterprise content management, EAI, CRM, enterprise infrastructure, and web services. Gary has been the lead architect for multiple web services projects. He can be reached at gmeyer@eforceglobal.com.

    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
    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...
    When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
    SYS-CON Events announced today that App2Cloud 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. App2Cloud is an online Platform, specializing in migrating legacy applications to any Cloud Providers (AWS, Azure, Google Cloud).
    IoT is at the core or many Digital Transformation initiatives with the goal of re-inventing a company's business model. We all agree that collecting relevant IoT data will result in massive amounts of data needing to be stored. However, with the rapid development of IoT devices and ongoing business model transformation, we are not able to predict the volume and growth of IoT data. And with the lack of IoT history, traditional methods of IT and infrastructure planning based on the past do not app...
    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. Jack Norris reviews best practices to show how companies develop, deploy, and dynamically update these applications and how this data-first...
    Internet-of-Things discussions can end up either going down the consumer gadget rabbit hole or focused on the sort of data logging that industrial manufacturers have been doing forever. However, in fact, companies today are already using IoT data both to optimize their operational technology and to improve the experience of customer interactions in novel ways. In his session at @ThingsExpo, Gordon Haff, Red Hat Technology Evangelist, shared examples from a wide range of industries – including en...
    Intelligent Automation is now one of the key business imperatives for CIOs and CISOs impacting all areas of business today. In his session at 21st Cloud Expo, Brian Boeggeman, VP Alliances & Partnerships at Ayehu, will talk about how business value is created and delivered through intelligent automation to today’s enterprises. The open ecosystem platform approach toward Intelligent Automation that Ayehu delivers to the market is core to enabling the creation of the self-driving enterprise.
    "We're a cybersecurity firm that specializes in engineering security solutions both at the software and hardware level. Security cannot be an after-the-fact afterthought, which is what it's become," stated Richard Blech, Chief Executive Officer at Secure Channels, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
    Consumers increasingly expect their electronic "things" to be connected to smart phones, tablets and the Internet. When that thing happens to be a medical device, the risks and benefits of connectivity must be carefully weighed. Once the decision is made that connecting the device is beneficial, medical device manufacturers must design their products to maintain patient safety and prevent compromised personal health information in the face of cybersecurity threats. In his session at @ThingsExpo...
    SYS-CON Events announced today that Grape Up 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. Grape Up is a software company specializing in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market across the U.S. and Europe, Grape Up works with a variety of customers from emergi...
    Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
    SYS-CON Events announced today that Massive Networks 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. Massive Networks mission is simple. To help your business operate seamlessly with fast, reliable, and secure internet and network solutions. Improve your customer's experience with outstanding connections to your cloud.
    Because IoT devices are deployed in mission-critical environments more than ever before, it’s increasingly imperative they be truly smart. IoT sensors simply stockpiling data isn’t useful. IoT must be artificially and naturally intelligent in order to provide more value In his session at @ThingsExpo, John Crupi, Vice President and Engineering System Architect at Greenwave Systems, will discuss how IoT artificial intelligence (AI) can be carried out via edge analytics and machine learning techn...
    Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution and join Akvelon expert and IoT industry leader, Sergey Grebnov, in his session at @ThingsExpo, for an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
    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, will examine the regulations and provide insight on how it affects technology, challenges the established rules and will usher in new levels of diligence a...
    In the enterprise today, connected IoT devices are everywhere – both inside and outside corporate environments. The need to identify, manage, control and secure a quickly growing web of connections and outside devices is making the already challenging task of security even more important, and onerous. In his session at @ThingsExpo, Rich Boyer, CISO and Chief Architect for Security at NTT i3, discussed new ways of thinking and the approaches needed to address the emerging challenges of security i...
    SYS-CON Events announced today that Datera, that offers a radically new data management architecture, has been named "Exhibitor" of 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. Datera is transforming the traditional datacenter model through modern cloud simplicity. The technology industry is at another major inflection point. The rise of mobile, the Internet of Things, data storage and Big...
    An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics ...
    SYS-CON Events announced today that Datera 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. Datera offers a radically new approach to data management, where innovative software makes data infrastructure invisible, elastic and able to perform at the highest level. It eliminates hardware lock-in and gives IT organizations the choice to source x86 server nodes, with business model option...
    With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, Cloud Expo and @ThingsExpo are two of the most important technology events of the year. Since its launch over eight years ago, Cloud Expo and @ThingsExpo have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, I provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading the...