Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jax-ws regarding endpointinterface

have defined a Java Interface with the annotation @WebService Compiled the code which went fine

Example:

@WebService
public interface HelloWorldIfc{

Now I tried to define an endpointinterface as

 @WebService (endpointInterface = "com.ws.HelloWorldIfc")
    public interface HelloWorldIfc{

This compiled fine too

So - should I be defining the endpoint interface on the interface or on implementing class ?
is this attribute of any use - what is its purpose ?
what happens if I dont define it - what do I lose ?
Thanks,
satish

like image 988
satish marathe Avatar asked Jan 14 '13 14:01

satish marathe


People also ask

What is the use of @WebService annotation?

The annotation @WebService tells the server runtime environment to expose all public methods on that bean as a web service. You can control more levels of granularity by adding other annotations on individual methods or parameters. Using annotations makes it much easier to expose Java artifacts as web services.

What is JAX-WS RI?

JAX-WS is the strategic programming model for developing web services and is a required part of the Java Platform, Enterprise Edition 6 (Java EE 6). JAX-WS is also known as JSR 224. Version 8.0 supports the JAX-WS Version 2.2 and Web Services for Java EE (JSR 109) Version 1.3 specifications.

What is JAX-WS how it is useful for describing SOAP web services?

JAX-WS is a technology for building web services and clients that communicate using XML. JAX-WS allows developers to write message-oriented as well as RPC-oriented web services. In JAX-WS, a web service operation invocation is represented by an XML-based protocol such as SOAP.


1 Answers

The JAX-WS Specification makes this cleas in section 3.3, page 30:

You can use the endpointInterface attribute to separate between the implementing class and the interface. Basically, this determines what will be mapped to your wsdl:portType when you deploy the service and the wsdl:definition is generated.

If you do not define the endpointInterface all public methods of the annotated class will be mapped to wsdl:operation (as long as you do not influence this behaviour with @WebMethod annotations).

If you do define the endpointInterface, it has to point to some type which the annotated class implements (or, well, itself as demonstrated in your question). Then, the public methods of this type are used for mapping the wsdl:portType, instead of the methods of the annotated class.

To sum up: The definition of endpointInterface only makes sense if you use the @WebService on an implementing class and want your WSDL to be generated based on the interface it implements. In your current setting where you use the annotation on the interface com.ws.HelloWorldIfc, there really isn't any difference. So you lose nothing by just skipping it. The annotation is useful if you want your implementation class to provide public methods that should not go into the generated WSDL.

like image 162
joergl Avatar answered Oct 09 '22 09:10

joergl