This recipe explains the possibilities of annotating a service endpoint interface with the @WebService
annotation. In the Annotating Java code for web service creation recipe in Chapter 8, Exposing Java Code as a SOAP Service, we covered a similar topic. Here, we provide a more in-depth view of the @WebService
annotation and explore the parameters we can set for the @WebService
annotation.
In this recipe, we will continue the development of the web service from the Creating a service endpoint interface recipe in this chapter.
Here are the steps we need to perform to annotate the SEI with the @WebService
annotation:
org.packt.cc.business.CCGateSvc
) and select the Properties… option in JDeveloper. The Java Web Service Editor opens where you can configure the web service creation process.CCGateSvc
as the service name and CCGateSvcPort
as the service port name.org.packt.cc.business.CCGatePortType
.Remember before we started changing the web service, the definition of the web service in CreditCardGateway.java
was:
@WebService(endpointInterface = "org.packt.cc.business.CreditCardGatewayPortType")
The new definition of the web service is given here:
@WebService(serviceName = "CCGateSvc", portName = "CCGateSvcPort", endpointInterface = "org.packt.cc.business.CCGatePortType")
By changing the service name (1) in the Java Web Service Editor, we set the serviceName attribute in the @WebService
annotation. When we change the port name (2) in the Java Web Service Editor, we set the portName attribute in the @WebService
annotation. By checking the Add SEI checkbox (3), we add the SEI into the JDeveloper project. Finally, autogenerate SEI name (4) in the
Java Web Service Editor affects the endpointInterface
attribute in the @WebService
annotation.
The @WebService
annotation also has the ability to set the name
(holding information about the web service name), targetNamespace
(identifies the namespace of the web service), and wsdlLocation
(when we have WSDL already defined, we set this attribute to point to it). It is not possible to set attributes in JDeveloper, however we can set them manually.