This discussion is archived
1 Reply Latest reply: Dec 11, 2012 6:20 PM by user696 RSS

WebMethod

tron Newbie
Currently Being Moderated
Can someone explain the difference between a plain public method versus using the @WebMethod statement before a public method?

I don't understand why @WebMethod is needed instead of just making publicly accessible things, public.
  • 1. Re: WebMethod
    user696 Explorer
    Currently Being Moderated
    Any public method is exposed as webservice method with default values. In the absence of @WebMethod, the value of the name attribute of the wsdl:operation element MUST be the name of the Java method.
    When using method-based injection, it is recommended that the method be declared as non-public, otherwise it will be exposed as a web service operation. Alternatively, the method can be marked with the @WebMethod(exclude=true) annotation to ensure it will not be part of the generated portType for the service.

    The javax.jws.WebMethod annotation MAY be used to customize the value of the name attribute of the wsdl:operation element and MUST be used to resolve naming conflicts.

    HTH
    Regards,
    Sunil P

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points