Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Complex Java Web Service

Posted on 2010-08-30
9
Medium Priority
?
654 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: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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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