Solved

Complex Java Web Service

Posted on 2010-08-30
9
649 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 

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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
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…
Suggested Courses

635 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