YOUR FEEDBACK
Jeremy Geelan wrote: In response to inquiries and suggestions from readers this lexicon has recently...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE 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.

YOUR FEEDBACK
Omar F. Rodriguez wrote: Hi after all we have reached one point, I was telling you before that you can make a deploy easier, with Tools like JBuilder, (I am not promoting Borlands products here) but Jbuilder has a wizard that makes Native Executables for every platform, even so there is Install Anywhere where you can create Installators (.EXE etc), There is one time when i create an EXE in Jbuilder using Java3D and also used Install Anywhere to help me unpack DLLs in the system, nothing impresive My opinion is that Sun has not the same vision that Microsoft, this is why i like Java because there is so many thing you can work with, not only one vendor, just my opinion. I learn something here
John Wright wrote: Java has always had a focus toward "web apps" and other than JVM version compatibility issues it does quite well for developing those. My interest has always been for desktop (and server) apps and not browser applets, etc. That''s very true, Java 3D is "new" relative to most of Java. And Java 3D is not a part of "standard" Java. The primary point of my original post was really the issue with the "JAR" extension being hijacked by other software products and the fact that deploying a desktop application is troublesome because of issues with the JAR extension and multiple JVM versions and/or the lack of a JVM on the client''s machine. Sun could help us a *lot* by providing a tool that would build an "exe" launcher that could test for an appropriate JVM and launch our .jar Java application without confusion for the user. Long ago Codewarrior included this as part of their IDE but...
Omar F. Rodriguez wrote: I have been working with Java making WEB apps and some Swing but mostly WEB (J2EE), refering to WEB i have found plenty of docs, But Something i think you are right in one thing that some autor mislead articles and docs. Some books have a very interesting title but lacks in examples But i think we missed the road, I have work with Borland JBuilder and Jdeveloper and i have done many of deployments, it´s not so hard (By the Way when i ment "new" it was comparing to other Java Techs, relative it would be more accurent)
John Wright wrote: {laugh} Java 3D isn''t "new" we released an online virtual world which we openned to the public almost two years ago and our virtual world was in development two years prior to that and I considered myself as "late" starting in Java 3D as I started with v1.2 (current version is 1.3.1). And Sun has halted development of Java 3D so at the moment most of the community considers it a "dead API". I think you misread me, the abundance of documentation is an excellent feature of Java! But sheer volume of documentation doesn''t mean that all of it is quality. Sun sends out developer hints regularly that teach a couple aspects of Java. This is an EXCELLENT aspect of Sun''s support of Java. These are GREAT! However I find it amusing that they sometimes explain that most of the examples in books and provided by us experts are wrong (we are just lucky our code happens to work 99% of the time...
Omar F. Rodriguez wrote: You just touch or mention a very funny fact. You know that because i had that problem years ago, because i let that some other program take care of MIME types in my machine, the OS manages that, some other application take control or care of that particular kind of file, JAR in this case, you are just mentioning little thing that can be solve, believe me i had those troubles too, my respect to you because your large career, sorry to hear about "No good documentation" But if there is no any Doc how is there are some many Java Developers? how DO they learn to do the things they must do to work? About Java3D if you read carefully EULA and other notes, is still newly created is something still in development, some people think that MS .NET is something NEW and Original, they copied everything that Java has been developing thru years,
John Wright wrote: There is a difference between what I desire as a seasoned technical veteran and what I want my users experience to be. Yes, for the naive user "Webstart" is a fascinating deployment idea (assuming they have Java already installed). But in my opinion it has many flaws. Java has a LOT of documentation (unfortunately not all of it very good). My personal library is now 24 Java books. I consider the availability of documentation an excellent feature of Java. Unfortunately once you get past doing the basics documented in the books the API documentation is often sparse or misleading. And I speak as a seven plus year veteran Java software developer. Windows has spoiled people - yes, why learn arcane complex technical tricks and details if you can just click and run something? I''ve deployed over a half dozen Java applications worldwide and I field a lot of confused questions wonderi...
Omar F. Rodriguez wrote: And One more thing is the same people that say that UNIX sucks comparing to Windows, why? because is much easier manage a Windows server that a UNIX to them. Windows world has spoiled many people
Omar F. Rodriguez wrote: I am agreed with Mr Joseph Ottinger, there is plenty of information, i dont really posses a great collection of books of Java, but when i´ve been searching an information i ´ve always found it, First Mr Wright said that Java Deployment is a nightmare, that´s a lie, because there plenty of tool that make easy a Java Deployment, but some pleople might say that because Java is not a Microsoft Full Wizard Language where the programmer has no knowledge of what is going on, Windows does Everything, Even i know some people that really think that Oracle suck comparing to MS SQL Server, well they say that because to them is really easy manage a DB like SQL Server, to them manage a ORacle DB is a nightmare. Why? because there are something that requires intelligence like in Java, not everything has to be done by wizard, besides there are a lot of programmers that want to make Javap rograms p...
Joseph Ottinger wrote: Mr. Wright - from the web start docs at http://java.sun.com/products/javawebstart/overview.html and other documentation, the JWS is started through the use of a browser object, which is not reliant on Java, unless I misinterpret the intent. Unfortunately, I don''t have a machine without Java installed to test with. Past that, I sort of understand your disgruntlement, although it seems contrary - you want your users to not have to interact with the installation, yet you complain that they don''t have any control over where files are located.
John Wright wrote: Mr. Ottinger, the first thing that is wrong with "Webstart" is that it requires the user to have Java installed in the first place. And this is problem because I have a number of customers that have software that only works with Microsoft''s VM and their tech support is requiring that Sun''s Java be removed. The second problem I have with Webstart is that it is "online". Many customers still have dial-up Internet access or are behind firewalls and are restricted in what they can do (if they even have Internet access at all). The third problem I have with it is that installation / webstart usage is completely out of the control of the user. It downloads files and places them in locations the user is unaware of or may not desire. I''ve personally experienced a few webstart applications that prompt the user to relax their security settings in order for the application to work. In times...
Joseph Ottinger wrote: Mr. Wright, what''s wrong with Webstart? When I used it, it worked; it was trivial; nothing really special or spectacularly wrong with it, and it was certainly trivial for a user to work with. That seems to *fit* your requirements. Further, what examples of bugs (or non-bugs) are you referring to?
John Wright wrote: Several excellent points: 1) Deployment of Java is a nightmare. The single biggest flaw of Java is the difficulty of deploying an application to a customer in a manner which is easy and foolproof for the customer. 2) Java needs to avoid feature creep. We don''t need all the fancy additional features. We need better documentation; a standard and reliable deployment scheme (NOT Webstart!!); we need reliable APIs (too many *bugs* are dismissed as not a bug and called "misunderstood documentation").
Omar F. Rodriguez wrote: This is my opinion and nothing more, but i dont think this a decision made from Java, be aside of microsoft, i think that microsoft made that step because the saw Java as a threat to them
LATEST JAVA STORIES & POSTS
What's the key to team and individual developer productivity in maintaining and extending a large application? Let’s start by making the following assertions: A developer's knowledge of an application code base is likely the single biggest factor of individual productivity. Cor...
An applet, a Java program that runs in a browser, often has to access the client resources. However, the security manager prevents an applet from accessing client resources. To access client resources, the applet has to have the proper permission. With this permission the applet ...
Three-letter acronyms (TLAs) are hardly new in Information Technology: EAI, ESB, SOA, BPM, BAM, ETL, MDM; the list goes on and on. This article is about yet another three-letter acronym, EDA, which stands for Event-Driven Architecture. EDA is not a brand new technology, but rathe...
Furthering its dedication to providing Java developers productivity with choice, Oracle announced the Oracle Enterprise Pack for Eclipse, a new component of Oracle Fusion Middleware. This release marks the first free Eclipse 3.4 environment to support Oracle WebLogic Server 10g R...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the ...
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

SPONSORED BY INFRAGISTICS
There are many forces that influence technological evolution. After a decade of building enterprise ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
In every field of design one of the first things students do is learn from the work of others. They ...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE
BREAKING JAVA NEWS

SpringSource, a leading provider of infrastructure software and the company behind ...