×
☰ See All Chapters

What is Endpoint

In general from web service provider the class or program which is responsible for exposing the service is an endpoint. In java the implementation class annotated with WebService annotation exposes the services to consumer and such implementation classed are called as endpoint.

SOAP JAX –WS we service endpoints must follow these requirements:

  • The implementing class must be annotated with either the javax.jws.WebService or javax.xml.ws.WebServiceProvider annotation. 

  • The implementing class may explicitly reference an SEI (Service Endpoint Interface) through the endpointInterface element of the @WebService annotation, but is not required to do so. If no endpoint interface is specified in @WebService annotation, an SEI is implicitly defined for the implementing class. But as the best practices tell us, we should first define an interface that declares all the methods to be exposed as a Web Service, and its implementation should define those methods. 

  what-is-endpoint-0
 
  • If any TO (transfer Objects) type is used in web service methods then those TO classes must implement Serializable interface. 

public class Employee implements Serializable {

        private String name;

            private int age;

            private int id;

            //setters and getters

}

 

  • Using javax.jws.soap.SOAPBinding annotation we can define the message exchanging formats. SOAPBinding annotation specifies the mapping of the Web Service onto the SOAP message protocol. 

Example:

import javax.jws.WebService;

import javax.jws.soap.SOAPBinding;

import javax.jws.soap.SOAPBinding.Style;

 

@WebService

@SOAPBinding(style = Style.RPC)

//@SOAPBinding(style = Style.DOCUMENT)

public interface HelloWorld{

……

}

 

Optional Element Summary

SOAPBinding.ParameterStyle

parameterStyle whether method parameters represent the entire message body, or whether the parameters are elements wrapped inside a top-level element named after the operation

SOAPBinding.Style

style defines the encoding style for messages send to and from the Web Service.

SOAPBinding.Use

use defines the formatting style for messages sent to and from the Web Service.

  • The business methods of implementing class must be public, and must not be declared as static or final. 

  • The business methods that are exposed to web services clients must be annotated with javax.jws.WebMethod 

  • The business methods that are exposed to web services clients must have JAX-B compatible parameters and return type. 

  • The implementing class must not be declared final and must not be abstract. 

  • The implementing class must have a default public constructor. 

  • The implementing class must not define finalize method. 

  • The implementing class may use javax.annotation.PostConstruct or javax.annotation.PreDestroy annotations on its methods for lifecycle events callbacks. 

  • The @PostConstruct method is called by the container before the implementing class begins responding to web service clients. 

  • The @PreDestroy method is called by the container before the endpoint is removed from the operation. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


All Chapters
Author