Java Reference
In-Depth Information
import javax.jws.soap.SOAPBinding;
@WebService(targetNamespace = "",
serviceName = "CalculatePowerService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class CalculatePowerWebService {
@WebResult(name = "result")
public double calculatePower(@WebParam(name = "base")
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 spe-
cified using serviceName is used to generate the name attribute in the service element
in the WSDL interface. If you don't specify the serviceName element, the server will
generate it using the default value, which is the bean class name appended with the ser-
In the next row, we state 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.
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 on the
assumption that you want to call the web service just like you would call a normal func-
tion or method that is part of your application code.
Search WWH ::

Custom Search