David Botterill's Weblog

« Previous day (Aug 22, 2006) | Main | Next day (Aug 23, 2006) »

20060823 Wednesday August 23, 2006

Refreshing Web Services in Java Studio Creator 2

In a previous developer's life, like almost two years ago, I worked on the web service consumption feature in Java Studio Creator.  I struggled with defining the scenario for "refreshing" a web service.  A developer has recently brought the subject up again so I though I would blog on the topic.  So in this blog, I'll cover how to "refresh" a WSDL in Java Studio Creator.

Required Background Information

Before I dive into the how-to, I need to cover some background information about scopes in Java Studio Creator.  There are basically two scopes in Java Studio Creator that matter for this discussion, IDE scope and Project scope.

IDE Scope

When you do an "Add web service..." using the following dialog, you are adding to the IDE scope.

Add web service

All web services in the IDE scope are available to all projects.  The "Web Services" node in the "Servers" window shows the IDE-scoped web services.

server window


Project Scope

When you use a web service in a web page, the web service is copied to the Project scope.  


There are two techniques for adding a web service to the web page and thus the Project scope, via the context menu and drag-n-drop.

With the visual designer showing the target page...

Context Menu: Entire Web Service
  1. Select a web service  from the "Web Services" node.
  2. Right-click on the web service and select "Add to page".
context menu
Web Service Added to Project Scope

This will add a web service client property to the page as shown in the Outline window and the web service client Jar files to the project as shown in the Projects window.

Context Menu: Web Service Method
  1. Select a web service method from the "Web Services" node.
  2. Right-click on the web service method and select "Add to page".
add method
Web Service Method Added to Project Scope

This will add a web service client property and a web service data provider to the page as shown in the Outline window and the web service client Jar files to the project as shown in the Projects window.  The web service data provider wraps the web service client.


Drag-n-Drop: Entire Web Service
  1. Select a web service  from the "Web Services" node.
  2. Drag the web service  and drop it on the visual designer background.  A component is not a valid drop target for an entire web service.
You'll get the same results as adding a web service from the context menu above.
Drag-n-Drop: Web Service Method
  1. Select a web service method  from the "Web Services" node.
  2. Drag the web service method and drop it either on the visual designer background or on a component.
You'll get the same results as adding a web service method from the context menu above.

On to Refreshing

The most common use case of refreshing a web service I've seen involves a developer who is trying to get a web service interface correct so they keep changing the WSDL.  When they change the WSDL, they'd like to "refresh" the view of what Creator sees as that web service.  So now that we've looked at the scope issue above, you should know that we need to refresh the web service in both the IDE and the Project scope.

Refreshing the Web Service in the IDE Scope

Unlike the EJB consumption in Java Studio Creator, the web service consumption doesn't have a "refresh" option.  I have some good excuses but I won't go into those here. :)  In order to refresh the web service in the IDE scope, if you want to use the same name, you need to delete the web service and re-add it.  If you are OK with keeping multiple versions of the web service around, you don't have to delete the old one.  Simply add the new one.  The new name will have a number postfixed that will be incremented each time you add the same named web service.

Refreshing the Web Service in the Project Scope

This is a little more involved.  As I discussed above, a web service client property and also a web service data provider property are added to the web page. Web service client Jar files are also added to the project libraries.  If you really want to refresh the web service, the safest way is to delete the web service artifacts and re-add the web service to the project.

For example, if I drag-n-drop the "WorldTime->web service in the "samples"  folder  to a web page, I'll have these web service client artifacts added.

  • Added to the Page (viewed in the Outline window) -  "worldTimeTzStampNow1" data provider and "worldTimeClient1" web service client.
  • Added to the Project window "Libraries" node - "worldtime.jar" and "worldtimeDesignTime.jar".  If a non-sample web service was added, the jar name will be prefixed with the web service name. like "TravelWS-".
So to refresh this web service in this project, I would delete the "worldTimeTzStampNow1" data provider and "worldTimeClient1" web service client from the Outline window and I would remove the "worldtime.jar" and "worldtimeDesignTime.jar" from the "Libraries" node.  Then I would again drag-n-drop the "WorldTime->web service in the "samples"  folder  to a web page.

Also note that if you've written code around the web service client, re-adding the web service increments the number in the name.  To change this, click on the "..." next to the name in the property for the web service client and change it back to the name you used in the code.  Here's an example of some code that uses "worldTimeClient1".

          try {
                this.staticText1.setText(this.worldTimeClient1.tzStampNow("MST"));
            } catch (Exception ex) {
                log("Error Description", ex);
            }

Here's a snapshot of what you would change.

name change


Now isn't that refreshing! :)

Cheers!
-David
Posted by David Botterill ( Aug 23 2006, 06:42:52 PM MDT ) Permalink Comments [3] del.icio.us | digg | technorati