jax-ws regarding endpointinterface

后端 未结 2 511
甜味超标
甜味超标 2021-02-05 19:09

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

Example:

@WebService
public interface H         


        
相关标签:
2条回答
  • 2021-02-05 19:19

    To define the endpointInterface is usefull because @WebParam annotations of the interface methodes are working without defining them again in the implementation class.

    0 讨论(0)
  • 2021-02-05 19:22

    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.

    0 讨论(0)
提交回复
热议问题