0

Can some one tell me the where should be @WebMethod used and where @Path or @RequestMapping should be used?

Recently I came through a code where @webmethod is used, till now I have been using @path and @requestmapping for implementing my webservices. Well, the code with Webmethod was using SOAP webservices.

Is it something to do with SOAP or REST? or Java or J2EE?

I have tried googling, but no success till now.

@WebMethod(operationName = "GetPendingrequest")
public abstract ERxPendingRequestsCounts getERxPendingCountsForProvider(@WebParam(name = "pvid") BigDecimal pvid)
  throws SystemFault,SecurityFault, IllegalArgumentFault;
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I think this should be helpful: https://stackoverflow.com/questions/38628374/difference-between-path-and-requestmapping-in-rest-webservice – tpschmidt Aug 08 '19 at 07:17
  • `@Path` is a JAX-RS annotation while `@RequestMapping` is used in a Spring application. You do not mention Spring so I assume that using the later annotation will not work for you. `@WebMethod` is SOAP while `@Path` REST; very different. –  Aug 08 '19 at 07:18

1 Answers1

4

@Path is a JAX-RS notation. @WebMethod is the standard JAX-WS notation that tells that this particular method should be exposed as a public operation of the WebService.

Note: JAX-RS is specification that deals with RESTful interfaces while JAX-WS is the corresponding one for SOAP.

You can find more details on standard JAX-WS annotations here: https://docs.oracle.com/cd/E13222_01/wls/docs92/webserv/annotations.html#wp1040606

Kavitha Karunakaran
  • 1,340
  • 1
  • 17
  • 32