Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Accessing a Web Service with WebSphere Studio Application Developer

Marc Krisjanous (marckris@au1.ibm.com), WebSphere Technical Team, IBM Australia

Marc Krisjanous is part of the IBM Australia/New Zealand WebSphere Technical team in Melbourne, Australia. He specializes in WebSphere Application Server, WebSphere Edge Server, and associated development tools such as WebSphere Studio Application Developer. Marc has worked on various e-business projects in the IT industry for six years. You can reach Marc at marckris@au1.ibm.com .

Summary:  This article shows you one of the WebSphere Studio Application Developer tools that can help you build the Java client functionality used to invoke a Web service. It also gives you a simple demonstration of the power of Web services by invoking a Delphi e-mail service using a Java client.

Date:  29 Mar 2002
Level:  Introductory

Activity:  2269 views
Comments:  

Introduction

Web services has been called the next holy grail for component reuse and language interoperability. With the release of IBM WebSphere® Studio Application Developer (Application Developer), developers have a much easier and faster way to build Web services.

This article shows you one of the Application Developer tools that can help you build the JavaTM client functionality used to invoke a Web service. It also gives you a simple demonstration of the power of Web services by invoking a Delphi e-mail service using a Java client.


Finding a Web service to consume

You've probably heard of Universal Description, Discovery, and Integration (UDDI) repositories that can store information about a business and the Web services that the business offers. There is, however, another way of publishing a Web service for consumption. A Web services portal is a Web site that lets Web service providers publish their Web services for consumption.

In this article, we'll access the Web services portal XMethods, search for a Web service, and invoke it from a Java client. XMethods is a free public resource that lets Web service providers publish their Web service information for consumption, and provides a central location for Web service consumers. (The XMethods site is for testing only and is not supported for production use.) XMethods offers Web services with various functions and implementation languages such as Microsoft® SOAP, Apache SOAP, GLUE, and Delphi. If you search the XMethods site for "email" (no hyphen), you'll find a Web service called "Send an Email" that provides basic e-mail functionality and is implemented in Delphi. Clicking on the name takes you to an information page that provides all the information that you need to invoke the Web service, including name, publisher, toolkit, and a link to the Web Services Description Language (WSDL) file.


Downloading and importing the WSDL file

WSDL is a common framework for describing the tasks performed by a Web service. In order to use the e-mail Web service, you need to download its WSDL file and save it on your machine. Some Web browsers may save the WSDL file as an XML file -- if that happens, change the file extension to WSDL. Next, in order to use the WSDL to create a Web service client, import the file into an existing Web project in Application Developer:

  1. In your Web project, create a folder named wsdl underneath the webApplication folder.
  2. Select File => Import. From the Import dialog box, select File system.
  3. Navigate to the WSDL file and click Finish. The WSDL file will be imported into the Web project.

Running the Web service client wizard

Application Developer provides a wizard that generates client proxies and a sample application for invoking Web services. We will use the wizard to create all the code that is required to invoke the Web service. To do this, follow the steps below.

  1. Select the WSDL file within the Web project. Select File => New.

  2. In the New dialog box, select Other. Select Web Services from the left panel and Web Service Client from the right panel. Click Next. The Web Service Client dialog box will open, as shown in Figure 1 below.
    Figure 1.

  3. The Web Service Client dialog box gives you a selection of options when creating the client functionality. First, make sure that the correct Web project has been selected.

  4. We will get Application Developer to generate the proxy classes and a sample application to run the Web service. Click the Generate a proxy, Generate a sample, and Launch the sample check boxes. Then click Next. The Web Service Client wizard prompts for the WSDL file. This enables the wizard to generate the proxy and sample code required to invoke the Web service.

  5. Click Next. The wizard reads the WSDL file and lists the available services, including the parameters required and the response objects sent back to the client. Keep the default functionality offered and click Next, Next again, and then Finish.

    The wizard generates the required proxy classes and sample application. Application Developer then publishes the application to the internal WebSphere Application Server and launches it. If successful, you will see Application Developer swap to the Server perspective and display the sample application input Web page.

  6. Select the SendEmail URL located on the Methods frame, as shown in Figure 2 below.
    Figure 2.

  7. When reading the WSDL file, Application Developer identifies the four parameters required to invoke the Web service. The Web page above contains text boxes for the four parameters, and the next step is to enter data into them. When the application is invoked, an e-mail will be sent to the address you enter in the ToAddress text box.

  8. Enter a valid recipient e-mail address in the ToAddress text box. Enter your e-mail address in the FromAddress text box. Enter in a brief subject and message in the ASubject and MsgBody text boxes. After entering the data, click Invoke.

  9. The sample application will then invoke the Web service via the proxy classes generated. If the invocation is successful, the Web service will return a 0, and you will see the result of the invocation in the Result frame of the Web page.

  10. Check the recipient's e-mail account! It should contain an e-mail sent by the Web service.

Summary

We have used a Web service within a Java application to send an e-mail with a brief message. We used Application Developer to generate the Java proxies required to invoke the Web service. The proxy classes can be reused in any project that wants to use this Web service. Application Developer also generated a sample application that let us invoke the Web service. Notice that the Web service is implemented in Delphi, but we have no idea (nor do we care) where the Web service is located or what operating system it is running on! If you want to, you can export the sample application as a WAR or EAR file, upload it to WebSphere Application Server 4.0, and ask other people to test the functionality.


Looking ahead

A future article will show you how to convert existing Java functionality into a Web service, deploy to an application server, and enable it for consumption by other applications.

Web services is still young, and standards such as WSDL, UDDI, and SOAP are still being standardized. Organizations and committees such as W3C, the Java Community Process (JCA), and the Web Services Interoperability Organization (WS-I) are working to provide standards and interoperability across vendors. The next question you may ask is how could you charge for this service and how could you rate it in regards to Quality of Service (QoS)? IBM has introduced the Web Services Hosting Technology toolkit, a technology preview that you can download from IBM alphaWorks. It lets Web service providers rate their Web services for QoS, and define offers for Web services. Customers can register with the run-time functionality, and choose Web service offers that they want to use. The toolkit also provides a lightweight invoice system that demonstrates how you can bill users for using your Web service.


Resources

About the author

Marc Krisjanous is part of the IBM Australia/New Zealand WebSphere Technical team in Melbourne, Australia. He specializes in WebSphere Application Server, WebSphere Edge Server, and associated development tools such as WebSphere Studio Application Developer. Marc has worked on various e-business projects in the IT industry for six years. You can reach Marc at marckris@au1.ibm.com .

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=13845
ArticleTitle=Accessing a Web Service with WebSphere Studio Application Developer
publish-date=03292002
author1-email=marckris@au1.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers