4. SOAP - XML Web Services using Java
4. SOAP - XML Web Services using Java
WEB SERVICES
• It is a type of web application which is used to share the message
between client and server (Communication between two devices on a
network)
• Unlike web applications, the main benefit of web service supports the
code reusability. A single web service can be used by different kinds of
applications
• The main component of a web service is the data which is shared
between client and server
• It is a client server application for creating communication between two
devices over network for exchanging data
1
| Java XML Web Services 24 |
3
| Java XML Web Services 24 |
4
| Java XML Web Services 24 |
5
| Java XML Web Services 24 |
6
| Java XML Web Services 24 |
7
| Java XML Web Services 24 |
8
| Java XML Web Services 24 |
2. SOURCE CODE
(NewWebService.java)
package tp;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@WebService(serviceName = "NewWebService")
public class NewWebService
{
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
@WebMethod()
public String Add(int a, int b)
{
int c=a+b;
return "Sum is: "+Integer.toString(c);
}
@WebMethod()
public String Sub(int a, int b)
{
int c=a-b;
return "Sub is: "+Integer.toString(c);
}
@WebMethod()
public String Mul(int a, int b)
{
int c=a*b;
9
| Java XML Web Services 24 |
10
| Java XML Web Services 24 |
3. OUTPUT
3.1 DEPLOYING THE PROJECT BEFORE TESTING THE WEB SERVICE
→ RIGHT CLICK ON THE CURRENT PROJECT AND SELECT DEPLOY
OPTION
11
| Java XML Web Services 24 |
12
| Java XML Web Services 24 |
13
| Java XML Web Services 24 |
14
| Java XML Web Services 24 |
15
| Java XML Web Services 24 |
16
| Java XML Web Services 24 |
17
| Java XML Web Services 24 |
18
| Java XML Web Services 24 |
19