Register Login
Internet / AI Technology University (ITU/AITU)





|

Top Links: >> 80. Technology >> Internet Technology Summit Program >> 4. Web Apps Frameworks
Current Topic: 4.5. Web Services
Sub-Topics: 4.5.1. REST Web Services
-- Scroll to check for more content below...
You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
What Are Web Services?

Web services are client and server applications that follow Web Services W3C standards while transferring messages over the Internet with HyperText Transfer Protocol (HTTP). Simple services can interact with each other to provide composite services.

Web services can be distinguished as “big” or SOAP-based web services and “RESTful” web services.

Big web services use XML messages that follow the Simple Object Access Protocol (SOAP) standard. A message architecture and message formats are defined in XML with machine-readable descriptions written in the Web Services Description Language (WSDL).

Representational State Transfer (RESTful) web services do not require XML and much easier to develop and consume than “big” SOAP-based web services. RESTful services use HTTP methods: GET, POST, PUT and DELETE while transferring information and managing data over the Internet.

Java Enterprise Edition (EE) supports SOAP-based web services with JAX-WS API and RESTful services with JAX-RS API.

JAX-WS: addresses advanced Quality of Service (QoS) requirements and supports the WS-* set of protocols, which provide standards for security and reliability often important for enterprise and their clients.

JAX-RS: makes it easier to write web applications and makes less constraints than “big” services, allows for more flexibility and simplicity.

Creating a SOAP-based Web Service

Let us create a web service using JAX-WS. We will provide an annotation @WebService, a hint for JAX-WS to do some work for us. To further simplify the code we provide another annotation @Stateless. This annotation simplifies some of the configuration issues and gives us nice options such as transactions and security.

Here is the example of a web service class below. Eclipse can create the WSDL file, which helps to discover and operate the service. Compressed in a war file, this class can be deployed into an application server, such as Tomcat and can be invoked over the Internet.


import javax.ejb.Stateless;
import javax.jws.WebService;

@Stateless
@WebService(
portName = "TrainingPort",
serviceName = "TrainingService",
targetNamespace = "http://ITUniversity.us/wsdl",
endpointInterface = "com.javaschool.Training.ws.TrainingWs")
public class Training implements TrainingWs {
private String trainingCourseName;
public String getTrainingCourseName() {
return trainingCourseName;
}

public void setTrainingCourseName(String trainingCourseName) {
this.trainingCourseName = trainingCourseName;
}
}
Was it clear so far? Highlight the text in question Or


Note, that the last line in the WebService annotation named endpoint interface.

First of all what is endpoint?

A web service endpoint is a server-side resource, usually a Java class, that can be referenced as the address for web services. A WSDL file provides descriptions for such a resource. The descriptions include the endpoint URL, which can be used to invoke a web service. These endpoint descriptions can also be used on the client side to generate code that can communicate SOAP messages to and from the web service.

And what is endpoint interface?

A full name is (SEI). SEI works as a usual Java Interface. It defines business methods that are implemented by a Java class that serves as a web service endpoint.
Strictly speaking, endpoint interfaces are not required, but recommended, especially, if more than one implementation is possible.


import javax.jws.WebService;

@WebService(targetNamespace = "http://ITUniversity.us/wsdl")
public interface TrainingWs {

public String getTrainingCourseName();

public void setTrainingCourseName(String trainingCourseName);
}


Assignments:

Create 4 QnA on the subject and email to dean@ituniversity.us

In Eclipse open a new Dynamic Web Project ItsWS and add to the Java Resources – src – a new package com.javaschool.Training.ws. Create the interface TrainingWs and then the implementation class Training.

Do right-mouse click on the implementation class and select Web Services – Create Web Service options. Select Server Runtime: Tomcat and Web Service Runtime: Apache Axis. Generate and deploy WSDL and test deployment.

Package all for deployment at a remote server and provide instructions for deployment in the same zip file.
Email to dean@ituniversity.us

Enhance the last project done in DataService framework to allow service access to major functions of the project.
Compress all sources in another zip file and email with deployment instructions to dean@ituniversity.us

We invite you to create your own questions and answers (QnA) to increase your rank and win the Top Creativity Prize!

Topic Graph | Check Your Progress | Propose QnA | Have a question or comments for open discussion?
<br/>import javax.ejb.Stateless;
<br/>import javax.jws.WebService;
<br/>
<br/>@Stateless
<br/>@WebService(
<br/>        portName = "TrainingPort",
<br/>        serviceName = "TrainingService",
<br/>        targetNamespace = "http://ITUniversity.us/wsdl",
<br/>        endpointInterface = "com.javaschool.Training.ws.TrainingWs")
<br/>public class Training implements TrainingWs {
<br/>    private String trainingCourseName;
<br/>    public String getTrainingCourseName() {
<br/>        return trainingCourseName;
<br/>    }
<br/>
<br/>    public void setTrainingCourseName(String trainingCourseName) {
<br/>        this.trainingCourseName = trainingCourseName;
<br/>    }
<br/>}
<br/>






Was it clear so far? Highlight the text in question

Or



Note, that the last line in the WebService annotation named endpoint interface.

First of all what is endpoint?

A web service endpoint is a server-side resource, usually a Java class, that can be referenced as the address for web services. A WSDL file provides descriptions for such a resource. The descriptions include the endpoint URL, which can be used to invoke a web service. These endpoint descriptions can also be used on the client side to generate code that can communicate SOAP messages to and from the web service.

And what is endpoint interface?

A full name is (SEI). SEI works as a usual Java Interface. It defines business methods that are implemented by a Java class that serves as a web service endpoint.
Strictly speaking, endpoint interfaces are not required, but recommended, especially, if more than one implementation is possible.

<br/>import javax.jws.WebService;
<br/>
<br/>@WebService(targetNamespace = "http://ITUniversity.us/wsdl")
<br/>public interface TrainingWs {
<br/>
<br/>    public String getTrainingCourseName();
<br/>
<br/>    public void setTrainingCourseName(String trainingCourseName);
<br/>}
<br/>


Assignments:

Create 4 QnA on the subject and email to dean@ituniversity.us

In Eclipse open a new Dynamic Web Project ItsWS and add to the Java Resources – src – a new package com.javaschool.Training.ws. Create the interface TrainingWs and then the implementation class Training.

Do right-mouse click on the implementation class and select Web Services – Create Web Service options. Select Server Runtime: Tomcat and Web Service Runtime: Apache Axis. Generate and deploy WSDL and test deployment.

Package all for deployment at a remote server and provide instructions for deployment in the same zip file.
Email to dean@ituniversity.us

Enhance the last project done in DataService framework to allow service access to major functions of the project.
Compress all sources in another zip file and email with deployment instructions to dean@ituniversity.us


We invite you to create your own questions and answers (QnA) to increase your rank and win the Top Creativity Prize!


Topic Graph | Check Your Progress | Propose QnA | Have a question or comments for open discussion?

Have a suggestion? - shoot an email
Looking for something special? - Talk to AI
Read: IT of the future: AI and Semantic Cloud Architecture | Fixing Education
Do you want to move from theory to practice and become a magician? Learn and work with us at Internet Technology University (ITU) - JavaSchool.com.

Technology that we offer and How this works: English | Spanish | Russian | French

Internet Technology University | JavaSchool.com | Copyrights © Since 1997 | All Rights Reserved
Patents: US10956676, US7032006, US7774751, US7966093, US8051026, US8863234
Including conversational semantic decision support systems (CSDS) and bringing us closer to The message from 2040
Privacy Policy