Adding a Web Service Operation

See Also 

After you create a web service, you implement its operations in the implementation class. You can add operations manually in the Source Editor, by using the Web Service Designer, or by using the Add Operation dialog box. In the latter case, the IDE automatically declares the operation in the Service Endpoint Interface (the "interface"), if there is one (it is optional in the JAX-WS programming model) and adds a skeleton method in the implementation class.

To add a web service operation:
  1. Open the Add Operation dialog box in one of three ways:
  2. Define the name, return type, parameters, and exceptions of the web service operation. For example, do the following if you want to create this operation:
        public int add(int a, int b) throws MyException  {
        return a + b;
        }
    
    1. Type add in the Name text box and choose int from the Return Type drop-down.
    2. Click Add.
    3. Choose int from the Type drop-down and type a in the Name text box. Click OK.
    4. Click Add.
    5. Choose int from the Type drop-down and type b in the Name text box. Click OK.

      It is not necessary to add the java.rmi.RemoteException exception, because the IDE does this for you.

    6. Click OK to create the operation.

      The IDE adds the skeleton of the operation to the implementation class and declares it in the interface.

    7. In the Source Editor, implement the web service operation. For example, you could add return a + b; between the braces. Do this in the implementation class, not in the interface (if you have a separate interface class).
See Also
About Web Services
About Implementing Web Services
Creating a Web Service from Java
Creating a Web Service from a WSDL File

Legal Notices