Practical 5 Cloud Computing Google App Engine
Practical 5 Cloud Computing Google App Engine
Experiment No. 5
Aim: To study & Implement Web services in SOAP for JAVA Applications.
Theory:
Web services are application components that are designed to support interoperable machineto-
machine interaction over a network. This interoperability is gained through a set of XMLbased open
standards, such as the Web Services Description Language (WSDL), the Simple
Object Access Protocol (SOAP), and Universal Description, Discovery, and Integration (UDDI).
These standards provide a common and interoperable approach for defining, publishing, and
Choosing a Container:
You can either deploy your web service in a web container or in an EJB container. This depends
On your choice of implementation. If you are creating a Java EE application, use a web container
In any case, because you can put EJBs directly in a web application. For example, if you plan to
Deploy to the Tomcat Web Server, which only has a web container; create a web application, not
An EJB module.
Choose File > New Project. Select Web Application from the Java Web category
Right-click the Calculator WS Application node and choose New > Web
Service.
If you are creating a Java EE project on Glass Fish or WebLogic, select Implement Web
Click Finish. The Projects window displays the structure of the new web service and the
Source code is shown in the editor area.
The goal of this exercise is to add to the web service an operation that adds two numbers received
From a client. The NetBeans IDE provides a dialog for adding an operation to a web service. You
Can open this dialog either in the web service visual designer or in the web service context menu.
Click Add Operation in either the visual designer or the context menu. The Add
in the upper part of the Add Operation dialog box, type add in Name and type int in
in the lower part of the Add Operation dialog box, click Add and create a parameter of
Remove the default hello operation, either by deleting the hello () method in the source
Code or by selecting the hello operation in the visual designer and clicking remove
Operation.
created the service as a Java EE stateless bean or not. Can you see the difference in the
Note. In NetBeans IDE 7.3 and 7.4 you will notice that in the generated @WebService annotation the
9. In the editor, extend the skeleton add operation to the following (changes are in bold):
@WebMethod
int k = i + j;
return k;
As you can see from the preceding code, the web service simply receives two numbers and then
returns their sum. In the next section, you use the IDE to test the web service.
After you deploy a web service to a server, you can use the IDE to open the server's test client, if
the server has a test client. The GlassFish and WebLogic servers provide test clients.
If you are using the Tomcat Web Server, there is no test client. You can only run the project and
see if the Tomcat Web Services page opens. In this case, before you run the project, you need to
make the web service the entry point to your application. To make the web service the entry point
to your application, right-click the CalculatorWSApplication project node and choose Properties.
Open the Run properties and type /CalculatorWS in the Relative URL field. Click OK. To run
the project, right-click the project node again and select Run.
Right-click the project and choose Deploy. The IDE starts the application server, builds the
application, and deploys the application to the server. You can follow the progress of these
2. In the IDE's Projects tab, expand the Web Services node of the
The IDE opens the tester page in your browser, if you deployed a web application to the
GlassFish server. For the Tomcat Web Server and deployment of EJB modules, the
situation is different:
If you deployed to the GlassFish server, type two numbers in the tester page, as shown
below:
Now that you have deployed the web service, you need to create a client to make use of the web
service's add method. Here, you create three clients— a Java class in a Java SE application, a
Note: A more advanced tutorial focusing on clients is Developing JAX-WS Web Service
Clients.
In this section, you create a standard Java application. The wizard that you use to create the
application also creates a Java class. You then use the IDE's tools to create a client and consume
the web service that you created at the start of this tutorial.
Choose File > New Project (Ctrl-Shift-N on Linux and Windows, ⌘-Shift-N on MacOS).
Select Project as the WSDL source. Click Browse. Browse to the CalculatorWS web service
in the CalculatorWSApplication project. When you have selected the web service, click OK.
The Projects window displays the new web service client, with a node for the add method
that
you created:
Double-click your main class so that it opens in the Source Editor. Drag the add node
Note: Alternatively, instead of dragging the add node, you can right-click in the editor
and then choose Insert Code > Call Web Service Operation.
8. In the main() method body, replace the TODO comment with code that initializes
{ int i = 3;
int j = 4;
System.out.println("Result = " +
result);
run:
Re sul t = 7
Conclusion:
Thus we have studied use of webservices using SOAP for a java application