eclipse 在哪里包含 @Webresult ,@WebMethod 等

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32521401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:51:17  来源:igfitidea点击:

Where to include @Webresult ,@WebMethod etc

javaeclipseweb-servicesjax-wsrad

提问by Friendy

I have created a JaX Webservice through RAD(eclipse), and I am able to use the @WebParam annotation with my function parameter, however I also want to use @webresult etc but Don't know where should i specify them, on google I got interfaces but here i only have class and delegate class.

我已经通过 RAD(eclipse) 创建了一个 JaX Webservice,并且我能够将 @WebParam 注释与我的函数参数一起使用,但是我也想使用 @webresult 等但不知道我应该在哪里指定它们,在 google 上我有接口,但在这里我只有类和委托类。

my class is

我的课是

       public class GetFPDDataClass {

         public String GetFPDDataInput(String PolicyNumber)
         {

            return PolicyNumber;
         }

        }

and this is my delegate class

这是我的委托类

   @WebService (targetNamespace="fpd",   serviceName="GetFPDDataClassService", portName="GetFPDDataClassPort")
 public class GetFPDDataClassDelegate{

   fpd.GetFPDDataClass _getFPDDataClass = null;
     public String GetFPDDataInput (@WebParam(name="PolicyNumber") String PolicyNumber) {
      return _getFPDDataClass.GetFPDDataInput(PolicyNumber);
   }

    public GetFPDDataClassDelegate() {
        _getFPDDataClass = new fpd.GetFPDDataClass(); }

      }

回答by Gas

Both @WebResultand @WebMethodare set on the method level.

这两个@WebResult@WebMethod是在方法级别设置。

@WebResultis used to customize name of the XML element that represents the return value.

@WebResult用于自定义表示返回值的 XML 元素的名称。

@WebMethodis used to mark business methods that are exposed to web service clients. By default all public methods in your class are exposed, if you don't implement web service interface.

@WebMethod用于标记向 Web 服务客户端公开的业务方法。默认情况下,您的类中的所有公共方法都会公开,如果您没有实现 Web 服务接口。

Example:

例子:

 @WebMethod
 @WebResult(name="hellomessage")
 public String getHello() {
     ....
}

UPDATE:

更新:

If I dont have @WebResultI see the following xml:

如果我没有,@WebResult我会看到以下 xml:

<ns2:getHelloResponse>
    <return>hello fff</return>
</ns2:getHelloResponse>

with @WebResult:

@WebResult

<ns2:getHelloResponse>
   <hellomessage>hello fff</hellomessage>
 </ns2:getHelloResponse>