Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
borderStylesolid
titleCalculator.java
package org.apache.geronimo.samples.jws;

import javax.jws.WebServiceWebMethod;
import javax.jws.WebParam;
import javax.jws.WebMethodWebResult;
import javax.jws.WebParam.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(name = "CalculatorPortType",
            targetNamespace = "http://jws.samples.geronimo.apache.org")
public interface Calculator {

    @WebMethod/**
    public int add(@WebParam(name = "value1") int* @param value1,
     * @param value2
     * @return returns int
     */
    @WebMethod(operationName = "add")
    @WebResult(name = "return", targetNamespace = "http://jws.samples.geronimo.apache.org")
    @RequestWrapper(localName = "add", targetNamespace = "http://jws.samples.geronimo.apache.org", className = "org.apache.geronimo.samples.jws.Add")
    @ResponseWrapper(localName = "addResponse", targetNamespace = "http://jws.samples.geronimo.apache.org", className = "org.apache.geronimo.samples.jws.AddResponse")
    public int add(@WebParam(name = "value1", targetNamespace = "http://jws.samples.geronimo.apache.org")int value1,
                   @WebParam(name = "value2") , targetNamespace = "http://jws.samples.geronimo.apache.org")int value2);

}

The CalculatorService class implements the Web Service business logic. It implements all the methods defined in the SEI. The class does not need to implement the Calculator interface but must reference it through the @WebService.endpointInterface annotation. This class will be exposed as a Servlet through web.xml file even though it does not extend the javax.servlet.Servlet class.
The context variable marked with the @Resource annotation will be injected at runtime. The WebServiceContext can be used to obtain the message context and security information relative to the call.

...