Solved

Complex Java Web Service

Posted on 2010-08-30
9
618 Views
Last Modified: 2013-11-21
Greetings Web Services Experts,
As a newbie to Web Services, I've been reading about SOA design concepts.  Also, using NetBeans 6.7, I have gone through the tutorials on building web services, clients and tried out all the Web Services examples.  However, I'd like to go beyond the "Hello World" web service.  At work, I need to write a web service that interfaces with a legacy application that outputs data constantly and am not sure where to begin (Hello World can only show so much).  Are there any examples of real-life Java web services implementations?

Thanks in advance!
0
Comment
Question by:Lee_Dev
  • 5
  • 3
9 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33567003
<<Are there any examples of real-life Java web services implementations?>>
check these
http://www.webservicex.net/WS/wscatlist.aspx

If just google "free web services", you will get many links which can give you live examples
like http://developer.yahoo.com/maps/rest/V1/geocode.html
0
 

Author Comment

by:Lee_Dev
ID: 33573451
I appreciate your help, gurvinder372.  The links you posted have very good information!  I saved them for future reference.  They will definitely come in handy when I need to look things up.  However, I'm looking for is Java code examples of Web Services (Not "Hello World" but real-life web services).  Any thoughts?
0
 
LVL 2

Expert Comment

by:arch-itect
ID: 33622470
>>a legacy application that outputs data constantly

In what format is this data?  Is this a port or is it written to a file?  Can it be redirected to the inputstream of your application?

Do you need to send a command to the legacy application before it gives you a block of data?

This is important when you want to design the server side.  Once the server side (service) is done you can generate the client.
0
 

Author Comment

by:Lee_Dev
ID: 33624167
Thanks for the follow up on my question, arch-itect.  I have a legacy app that outputs temperature measurements.  For example, "Temperature1, 70 degrees"; "Temperature 2, 80 degrees". These temperature values can be stored in arrays in a web service to be retrieved.  A web client will obtain the data and display it on a browser in real time (i.e. temperature updates every second). The question I have is that should I push the data from the Web Service to the Web Client or should the Web Client pull the data every second?  Also, what technology should I use on the web client side (e.g. AJAX, JSP, etc.)? Thank you in advance.
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 2

Accepted Solution

by:
arch-itect earned 250 total points
ID: 33627707
The web client will always have to pull the data.  Even push technology in web services is based on a "long get" a.k.a. comet.  Comet is exactly the same as Ajax except that it looks like a push.

I would use ajax in a loop over an XHR xml http request.

while (...) {
  ajax.post(...);
}

Have a look at dhtml goodies for some nice ajax tools:
http://www.dhtmlgoodies.com/index.html?page=ajax

In the browser the SOAP message is just xml so you will have to create and parse it yourself.
I have included a sample soap message below that you could post to the server.  

I would however suggest that you start with your hello world example and just rename the field and add another one for the temperature.  Then take the client message generated in the example and send (POST not GET) it from the browser using ajax.

Unless someone other than yourself are going to use this, you might not have to use a strict web service at all.  A simple ajax request would do the trick, but that is up to you.
        msg += ("<?xml version=\"1.0\" ?>\n");

        msg += ("<soap-env:Envelope \n");

        msg += ("	xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\" \n");

        msg += ("	xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" \n");

        msg += ("	soap-env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n");

        msg += ("	xmlns:xs=\"http://www.w3.org/1999/XMLSchema\" \n");

        msg += ("	xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\">\n");



        msg += ("<soap-env:Header xmlns:myNameSpace=\"http://www.myurl.org/messaging\">\n");



        msg += ("	<myNameSpace:tempName>" + getTempName() + "</myNameSpace:screen>\n");

        msg += ("	<myNameSpace:temperature>" + getTemperature() + "</myNameSpace:appName>\n");



        msg += ("</soap-env:Header>\n");

        msg += ("<soap-env:Body xmlns:meta=\"http://www.j4gl.org/messaging\">\n");

        msg += ("	<myNameSpace:form>\n");

        msg += ("	<!-- you could also use the body -->\n");

        msg += ("	</myNameSpace:form>\n");

        msg += ("</soap-env:Body>\n");

        msg += ("</soap-env:Envelope>\n");

Open in new window

0
 

Author Comment

by:Lee_Dev
ID: 33630428
Thank you arch-itect.  The data and suggestion you provided is very informative!  I'm testing out the "Hello World" Ajax (using NetBeans 6.7) like you have advised.  I'll let you know how this goes once I have it up and running with my Web Service.
0
 

Author Comment

by:Lee_Dev
ID: 33648765
Hi arch-itect, I'm still working on the AJAX web client.  However, I've been doing research on Comet technology (server push) that you mentioned.  Isn't it more suitable for this purpose?  Searching the web, it seems to me that Comet is not a "main stream" technology (i.e. not as well known as AJAX).  If you get a chance, I would like to hear your thoughts?  Thanks in advance.
0
 
LVL 2

Expert Comment

by:arch-itect
ID: 33665126
Hi Lee, yes, the comet name is not so popular, maybe because it has limited application.  Not many people stare at the same page for an extended period of time.  You can see it in action in facebook, where new notifications show up automatically, or gmail where mail is downloaded automatically (although that uses google gears), but it works on the same principle.  I suppose even the example above, of ajax in a loop, is an example of comet.  It is definitely useful in your case, and it won't affect your design much, at least not on the server side.  At the client, comet would just mean that you initiate another http get as soon as the previous one completes.  
0
 

Author Comment

by:Lee_Dev
ID: 33681087
Thank you arch-itect, for all your help!  The information you provided has given me a jump start on my web service development.  I got the prototype AJAX web client working with a servlet running on the server side.  I'm looking forward to the next step, which is to make it talk SOAP directly to my web service (with the information you provided).  You have answered all my questions.  Thnx!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now