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
The JAX-WS Specification makes this cleas in section 3.3, page 30:
You can use the
endpointInterfaceattribute to separate between the implementing class and the interface. Basically, this determines what will be mapped to yourwsdl:portTypewhen you deploy the service and thewsdl:definitionis generated.If you do not define the
endpointInterfaceall public methods of the annotated class will be mapped towsdl:operation(as long as you do not influence this behaviour with@WebMethodannotations).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 thewsdl:portType, instead of the methods of the annotated class.To sum up: The definition of
endpointInterfaceonly makes sense if you use the@WebServiceon 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 interfacecom.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.