Comments
litl_phil wrote: While it's nice that Google and Acer share the vision of cloud-based computing, it's also worth noting that we at litl already have a webbook on the market (available at litl.com) that runs our own cloud-based OS. Unlike Chrome, litlOS is focused on creating a new and better web experience for the home, so we don't have the usual browser interface, we have our own innovative UI. In conjunction with easel mode (litl's inverted-V position) and our growing cohort of litl channels (special apps t...
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Developing Web Services "Eclipse Web Tools Project"
Both bottom-up and top-down

Select the WSDL page icon (highlighted in the screen in Figure 7) in the Web Services Explorer then click WSDL Main in the right pane; this gives us the opportunity to invoke the Web Service directly by pointing to its WSDL. When you click "Browse," the screen shown in Figure 8 appears.

On this screen, a developer can select a project from an Eclipse Workspace then select the WSDL URL available in this project, in our case StockService.wsdl. Pressing Go and then Go again brings us back to the WSDL Explorer screen (see Figure 9), where all the methods exposed as part of our Web Service interface are generated:

You can specify the parameters (if any are required) and invoke this method as necessary by clicking on a particular method.

Now let's take a look at the entities that were generated. First of all, it's the WSDL file, StockService.wsdl that gets automatically generated under the Web Content\wsdl directory. Eclipse provides a superior editor for editing WSDL files as shown in Figure 10.

It includes the following four major interrelated entities that describe every Web Service:

  • Types: A container for data type definitions using XML schema type system.
  • Messages: An abstract typed definition of the data being communicated. A message can have one or more typed parts, for example, the highlighted message getLatestDateTimeResponse has just one part that is its return parameter of xsd:date (XML Schema date type).
  • Port types: Abstract sets of one or more operations supported by one or more ports.
  • Operations: Abstract description of an action supported by the service that defines the input and output message as well as optional fault message.
  • Bindings: Concrete protocol and data format specification for a particular port type. The binding information contains the protocol name, the invocation style, a service ID, and the encoding for each operation.
  • Services: A collection of related ports.
  • Ports: Single endpoints, which are defined as an aggregation of the binding and network addresses.
Also, the Web Services client project StockWebClient got generated, where we have the following four classes:
  • StockServiceServiceLocator: the locator class has information about the Web Service, most importantly the address by which the service can be invoked (the HTTP address). The locator class is populated based on the content of the Web Service's WSDL file.
  • StockService: the service endpoint interface that is a local representation of a Web Service. Through this interface, appropriate methods will be invoked.
  • StockServiceSoapBindingStub: the stub that implements remote invocation methods defined by StockService interface.
  • StockServiceService: the service locator interface that defines methods implemented by service locator class.
To invoke our service from the client, we can construct the following simple Java application under our StockWebClient Web project as shown in Listing 1.

Invoking this client can be done simply through the command line or using the Eclipse: right-button menu, Run-As, Java Application. This demonstrates the remote communication that Web Services provide - we invoke a service that could be located on a different machine so long as we know the endpoint address of the service as defined in the StockServiceLocator. Here's the output of this class:

Stock name: Our Stock
Stock price: 30.63180066603478
Stock volume: 42475629656767

Building a Top-Down Web Service
The top-down approach is commonly used when we have a standard service definition and want to implement this definition to provide the requested service. Top-down Web Service design involves the following steps:

  • First, we locate the WSDL document (either someone gives it to us, or sends it to us via email, or we locate it in Web Services Inspection Language (WSIL) document. Web Services Inspection Language (WSIL) allows one to describe multiple WSDL documents located within a site. We can also search UDDI registry for our Web Service.
  • Next, we generate implementation skeleton (normally, a Java bean skeleton), which contains methods and parameters that we fill to implement our Web Service.
  • Finally, using this skeleton, we complete all the methods with the appropriate logic.
After highlighting our StockService.wsdl document under Web Content\WSDL, we can right-click and select the Web Services - Generate Java Bean Skeleton from the right-button context menu. This brings up the dialog shown in Figure 11.

It's very similar to the one we initially used in the Bottom-Up development section, when we clicked "Next"; it brings us to the screen where we can specify the location of the WSDL file as shown in Figure 12.

The next screen (see Figure 13) shows the service deployment configuration: which Web project, server, Web Services runtime, and J2EE version to deploy the new Web Service to. Note that we may want to select a different Web project (say StockWebOne) here so as not to overwrite our sample classes from the previous example.

Click Finish to generate a bunch of classes including the service endpoint interface, service locator, but also the most interesting of them, the StockServiceSoapBindingImpl class, where method stubs are provided for you to fill out the particular implementation of this Web Service as shown in Listing 2.

A developer has to fill out these method stubs with the appropriate logic - obviously the system can't do it automatically for him since the WSDL file that the Web Service is generated from in a top-down approach only has information about Web Service's interface, not the actual implementation.

Testing and Debugging Web Services
Testing and debugging Web Services is done using Web Services Explorer. It has three major panes: WSDL, WSIL, and UDDI. Each of these serves the purpose of finding and testing particular Web Services. In the WSDL pane you can do it directly by finding the WSDL document in your project. The WSIL pane makes it easier for a developer to locate and test a particular Web Service on a particular site. With the help of the UDDI interface, one can search private or public UDDI registries (a private registry usually belongs to a particular company and its intranet services, which are usually invoked by internal applications at that company. Public registries are available throughout the Internet and are hosted by companies such as Microsoft [see http://uddi.microsoft.com/] for public use.)

Another way to test Web Services is by generating sample JSP files that create a sample application communicating with the Web Service. This can be easily done by right-clicking on the Java Bean and selecting the Web Services - Generate Sample Pages after Web Service creation is finished.

You can also generate a client from a WSDL file. It will include the service locator, service binding stub, and service endpoint interface: right-click and select Web Services - Generate Client. This will let you construct a simple Java application using the generated classes, just as we did in top-down Web Services generation.

All Eclipse debugging facilities are available when testing Web Services. A developer can start servers in the debugging mode and set breakpoints at any line to do normal code debugging.

Eclipse also includes a TCP/IP monitor to watch the Web Service methods' executions. Figure 14 shows how the TCP/IP monitor lets you debug a Web Service by using a client that consists of generated sample JSP pages. The TCP/IP monitor contains three panes:

  • The right-top pane includes a list of the interactions (requests/responses) that have been done in chronological order. When a developer clicks on a particular interaction, the system displays the time of request, how long it took the system to respond (in milliseconds), and the type of protocol that was used (in our case, HTTP).
  • The left-bottom pane displays the contents of the SOAP envelope generated by the Web Service's request.
  • The right-bottom pane displays the SOAP response envelope. Whenever we invoke a particular Web Service, this pane is populated with the response of the server in the SOAP (XML-based) format.
A TCP/IP monitor is a powerful facility showing the data that are actually being sent through the wire and simplifies analyzing possible problems with the Web Services implementation. If a developer uses one of the Web Services Security standards such as encryption, it would also allow him or her to see whether the request and response were properly encrypted and are resilient to possible intruder attack. However, currently Eclipse WTP tooling doesn't support the Web Services Security standard; a developer has to manually refer to this facility if he or she is to leverage it.

Conclusion
In this article, we've shown you how to develop bottom-up and top-down sample Web Services using the Eclipse Web Tools Project. Future articles will cover developing database-driven Web Services, security issues, and interoperability between Java and .NET.

About Boris Minkin
Boris Minkin is a Senior Technical Architect of a major financial corporation. He has more than 15 years of experience working in various areas of information technology and financial services. Boris is currently pursuing his Masters degree at Stevens Institute of Technology, New Jersey. His professional interests are in the Internet technology, service-oriented architecture, enterprise application architecture, multi-platform distributed applications, and relational database design. You can contact Boris at bm@panix.com.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

EXCELLENT TUTORIAL! Can you please add the security portion to it?

The ClassNotFoundException is related to this bug, https://bugs.eclipse.org/bugs/show_bug.cgi?id=89922

Visit the link and vote for it to be fixed!

I don't know how the article author managed to complete the action.

I read this article. Its really a very good article to start creating a web service. I was trying to create a web service by following this article. But I faced an Exception Like:
IWAB0398E Error in generating WSDL from Java: java.lang.ClassNotFoundException: TestJavaWebService
java.lang.ClassNotFoundException: TestJavaWebService
at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:203)
at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)
at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079)
at org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask.execute(Java2WsdlAntTask.java:188)
at org.eclipse.jst.ws.internal.axis.consumption.core.command.Java2WSDLCommand.executeAntTask(Java2WSDLCommand.java:163)
at org.eclipse.jst.ws.internal.axis.consumption.core.command.Java2WSDLCommand.execute(Java2WSDLCommand.java:87)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.runCommand(CommandFragmentEngine.java:387)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.visitTop(CommandFragmentEngine.java:327)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.moveForwardToNextStop(CommandFragmentEngine.java:226)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager$5.run(SimpleCommandEngineManager.java:247)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:291)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:830)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager.runForwardToNextStop(SimpleCommandEngineManager.java:217)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.runForwardToNextStop(WizardPageManager.java:79)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.getNextPage(WizardPageManager.java:125)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleWizardPage.getNextPage(SimpleWizardPage.java:119)
at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:747)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:345)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:556)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809)
at org.eclipse.jface.window.Window.open(Window.java:787)
at org.eclipse.wst.command.internal.env.ui.widgets.popup.DynamicPopupWizard.run(DynamicPopupWizard.java:126)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:246)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3125)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2758)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)

I found all the build bath has already set to read the classfile for my Project. I am not getting any idea how to solve this problem . Can You please help me [debasism@cressanda.com]in this regard for which I will be really very much obliged.

Thanks in advance
Debasis

The zip file corruption seems to have been repaired. the problem I'm having is related to a feature request, https://bugs.eclipse.org/bugs/show_bug.cgi?id=89922

Following the tutorial did not work for me, I get an error when the WSDL is being generated

Hi Sir,
can you help me in making two Web Services cretaed by Eclipse WTP 3.1 communicate with each other, such that one is a client for the other...
It is very important to me.
Thanx&Best Regards
Sherif

Hi Sir,
The story is pretty helpful, but I need to make one Web Service a client to another...can you help me in this?

zip file is still corrupt. is anybody home?

The additional code zip file .. seems to be corrupted. While unzipping it says "invalid archive".. Can u have it fixed pls..

Thanks
Thiagu

Today's trend is to integrate existing systems in a standard way to make disparate implementations interoperate. Web Services and XML came along with the ability to provide a standard communication interface between these systems, as well as the standard description language - WSDL - the Web Services Description Language that lets those systems define the structure of the services they're providing.

The source files seem to be corrupt. Please post a new zip file.


Your Feedback
userfor544 wrote: EXCELLENT TUTORIAL! Can you please add the security portion to it?
Neill wrote: The ClassNotFoundException is related to this bug, https://bugs.eclipse.org/bugs/show_bug.cgi?id=89922 Visit the link and vote for it to be fixed! I don't know how the article author managed to complete the action.
Debasis wrote: I read this article. Its really a very good article to start creating a web service. I was trying to create a web service by following this article. But I faced an Exception Like: IWAB0398E Error in generating WSDL from Java: java.lang.ClassNotFoundException: TestJavaWebService java.lang.ClassNotFoundException: TestJavaWebService at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:203) at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100) at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079) at org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask.execute(Java2WsdlAntTask.java:188) at org.eclipse.jst.ws.internal.axis.consumption.core.command.Java2WSDLCommand.executeAntTask(Java2WSDLCommand.java:163) at org.eclipse.jst.ws.internal.axis.consumption.core.command.Java2WSDLCommand.execute(Java2WSDLCommand.java:87) at org.e...
Neill wrote: The zip file corruption seems to have been repaired. the problem I'm having is related to a feature request, https://bugs.eclipse.org/bugs/show_bug.cgi?id=89922 Following the tutorial did not work for me, I get an error when the WSDL is being generated
Sherif A. Gurguis wrote: Hi Sir, can you help me in making two Web Services cretaed by Eclipse WTP 3.1 communicate with each other, such that one is a client for the other... It is very important to me. Thanx&Best Regards Sherif
Sherif A. Gurguis wrote: Hi Sir, The story is pretty helpful, but I need to make one Web Service a client to another...can you help me in this?
freecouch wrote: zip file is still corrupt. is anybody home?
THIAGU wrote: The additional code zip file .. seems to be corrupted. While unzipping it says "invalid archive".. Can u have it fixed pls.. Thanks Thiagu
SYS-CON Italy News Desk wrote: Today's trend is to integrate existing systems in a standard way to make disparate implementations interoperate. Web Services and XML came along with the ability to provide a standard communication interface between these systems, as well as the standard description language - WSDL - the Web Services Description Language that lets those systems define the structure of the services they're providing.
Anand wrote: The source files seem to be corrupt. Please post a new zip file.
Enterprise Open Source Magazine Latest Stories . . .
Oracle seems to have divided the open source ranks over the MySQL delay it’s having closing its acquisition of Sun. Eben Moglin, the GPL’s most ardent defender and delineator, the lawyer who has worked hand in glove for years with the Free Software Foundation’s founder Richard Stallman...
Cloud computing is a game changer. The cloud is disrupting traditional software and hardware business models by disrupting how IT service gets delivered. Entrepreneurial opportunities abound as this classic disruptive technology begins to proliferate, so it is no surprise that SYS-CON'...
The irony is that Oracle has advanced MySQL, lost money in the process, and helped its competitors - all at the same time. When Oracle buys Sun and controls MySQL the gift (other than to Microsoft SQL Server) keeps on giving as the existential threat to RDBs is managed by Redwood Shore...
WSO2, the open source SOA company, today announced the launch of the WSO2 Cloud Platform. Available today, the new WSO2 Cloud Platform features a family of WSO2 Cloud Virtual Machines; WSO2 Cloud Connectors for enabling fast, secure cloud services; and the multi-tenant WSO2 Governance-...
Now, the open source Mozilla Thunderbird client software can be used with Open-Xchange collaboration software. The "Community OXtender for Thunderbird" software connector gives users full access to appointments and contacts stored in the Open-Xchange Server and enables them to use Thun...
Morph Labs, a leading provider of enterprise cloud computing technology, today announced an introductory trial of the Morph CloudServer, an open, standards-based server IT organizations can use to rapidly model and evaluate their cloud implementations. A miniature "Cloud Environment in...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE