Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Complex Java Web Service

Posted on 2010-08-30
9
Medium Priority
?
661 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:Gurvinder Pal Singh
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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
 
LVL 2

Accepted Solution

by:
arch-itect earned 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

972 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