关于端点接口的jax-ws [英] jax-ws regarding endpointinterface

查看:61
本文介绍了关于端点接口的jax-ws的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已定义了带有注释 @WebService 的Java接口 编译正常的代码

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

示例:

@WebService
public interface HelloWorldIfc{

现在我尝试将终结点接口定义为

Now I tried to define an endpointinterface as

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

这也很好

那么-我应该在接口上还是在实现类上定义端点接口?
这是什么用途的属性-它的用途是什么?
如果我不定义它会发生什么-我会失去什么?
谢谢,
讽刺

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

推荐答案

JAX -WS规范在第30页的3.3节中进行了说明:

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

您可以使用endpointInterface属性在实现类和接口之间进行分隔.基本上,这确定了在部署服务并生成wsdl:definition时将映射到wsdl:portType的内容.

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.

如果您定义endpointInterface,则带注释的类的所有公共方法都将映射到wsdl:operation(只要您不使用@WebMethod注释影响此行为).

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).

如果您要做定义endpointInterface,则它必须指向带注释的类实现的某种类型(或者,如您的问题所示).然后,使用这种类型的公共方法来映射wsdl:portType,而不是使用带注释的类的方法.

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.

总结:endpointInterface的定义仅在您在实现类上使用@WebService并希望根据其实现的接口生成WSDL时才有意义.在当前设置中,您可以在接口com.ws.HelloWorldIfc上使用批注,实际上没有任何区别.因此,仅跳过它就不会丢失任何内容.如果您希望实现类提供不应包含在生成的WSDL中的公共方法,则注释非常有用.

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.

这篇关于关于端点接口的jax-ws的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆