Java Reference
In-Depth Information
@WebMethod
@WebResult(name="result") [1]
public double
calculatePower(@WebParam(name="base") [2]double
base,@WebParam(name="exponent")double exponent
{
return Math.pow(base,exponent);
}
}
Inside the
@WebService
annotation, you can specify additional elements, such
as the
targetNamespace
element, that declares the namespace used for the
WSDL elements generated by the web service. If you don't specify this element, the
web service container will use the Java package name to generate a default XML
namespace.
You can also use the
serviceName
element to specify the Service name. The name
specified using
serviceName
is used for generating the name attribute in the Ser-
vice element in the WSDL interface. If you don't specify the
serviceName
element,
the server will generate it using the default, which is the bean class name appended
with the Service.
In the next row, we have stated that the web service is of the type Remote Procedure
Call using the
@javax.jws.SOAPBinding
annotation. The possible values are
DOCUMENT
and
RPC
, the first one being the default value.
Note
The choice between the RPC and Document style boils down to the different
ways we can construct Services using these two styles. The body of an RPC-
style SOAP message is constructed in a specific way, which is defined in the
SOAP standard. This is built around the assumption that you want to call the web
service just like you would call a normal function or method that is part of your
application code.