1

I am currently trying to implement a web-service assignment given by my college.

My Assignment is..,

Consider a case where we have two web Services- an airline service and a travel agent and the travel agent is searching for an airline. Implement this scenario using Web Services and Data base.

For that as a newbie I tried to follow the steps given in this link. I opened the Netbeans beta 2, and exactly followed the steps as given in that link.

But while trying the steps, Deploying and Testing the Web Service, I tried to run the CalculatorWSApplication, I noticed that javax.ejb.Stateless is undefined.

enter image description here

And I have three questions,

  1. I have a basic knowledge of , JSP, HTML, WEBSERVICE. Please give me some basic idea/basic schema of the assignment such that I could proceed with the next steps and implementation.
  2. How could I get rid-off from the missing ejb file.
  3. Generally .java files will refer to the libraries present in jre and why in this program, CalculatorWS.java refers in this path C:\users\MuthuGanapathy\.netbeans\7.0beta2\var\cache\index\s3\java\14\gensrc\javax\
Muthu Ganapathy Nathan
  • 3,199
  • 16
  • 47
  • 77

1 Answers1

1

Let me try to answer your questions:

First of all: You don't really need knowledge of JSP and HTML for creating WebServices. If you are interested in additional knowledge rather have a look in subjects like SOAP, WSDL or XML (on which SOAP and WSDL files are based). You can find good informations at w3schools.

As said in your assignments requirement you'll have combine your service with a database, therefore you'll have to face the fact that WebServices aren't able to send every kind of data. For example, if you intend to use some kind of JPA you wont be able to send entities between Client and Server via WebService easily (though its possible).

For the reason of that my approach would be to send simple datatypes between client and server and, on server side, build my complex objects.

This would force me to code at least 3 classes (one for each webservice and one for communication with the database).

Airline WS:

@WebService
public class Airline {

  @WebMethod
  public String stuffToDo {
    // do your stuff
    persistOrSelect(complexObject);
    return "success"; 
  }

  private boolean persistOrSelectData(Object complex) {
    // Database stuff here
    DBdao.doStuff(complex);
    return true;
  }
}

TravelAgent WS:

// same structure as shown above

DB class:

public class DBdao {

  public static doStuff(Object complex) {
    // get DB connection and INSERT, SELECT, UPDATE
  }
}

In this scenario you didn't even have to use a class out of the javax.ejb package but I understand that this could be necessary :).
I don't really use Netbeans and therefore I can only speculate. I think that your problems 2.) and 3.) relate to each other.

The javax.* package normally is located in your JDK and should be specified in your IDE inside the server library/target runtime your using.

  • Do you have assigned the server library to your project?
  • Have you tried to point your Netbeans installation to your JDK path as shown here and here?
  • It could also be possible that your project do not have a reference to the Java System library.

Last but not least:

There are several ways for testing your webservice:

  1. You use Netbeans therfore I assume that you deploy your project on an Glassfish server.
    After deployment you can navigate to your project inside the admin gui and click the link pointing to view endpoints. In the next window your able to either follow a link pointing to the generated WSDL or to a tester
  2. You can write your own client by either following the tutorial provided or, for a more general approach you can use this.
  3. Use soapUI for testing (it's available as standalone application or as IDE plugin)

I hope this helpes, have Fun!

Community
  • 1
  • 1
SimonSez
  • 7,399
  • 1
  • 30
  • 35