Annotating the service endpoint interface with @WebService

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.

Getting ready

In this recipe, we will continue the development of the web service from the Creating a service endpoint interface recipe in this chapter.

How to do it…

Here are the steps we need to perform to annotate the SEI with the @WebService annotation:

  1. Right-click on the web service class (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.
    How to do it…
  2. Enter CCGateSvc as the service name and CCGateSvcPort as the service port name.
  3. In the General Options section, we can configure the web service name, its port name, and check the service endpoint interface.
  4. Furthermore, in the Service Endpoint Interface dialog box, we configure the SEI parameters.
    How to do it…
  5. Select the Autogenerate Service Endpoint Interface option and enter org.packt.cc.business.CCGatePortType.

How it works…

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.

Note

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.

See also

To learn how to define various transport modes, refer to the Annotating the service endpoint interface with @SOAPBinding recipe in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset