Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Creating Web Service Applications wit... > Consuming a Web Service from a Servl...

Consuming a Web Service from a Servlet or EJB

Problem

You have an EJB, servlet, or other container-managed resource that you want to act as the client for your web service.

Solution

Use the @WebServiceRef annotation to inject a reference to the service you want to invoke. Note that this does not have to be only a servlet or EJB. You might also want to invoke a web service from other container-managed resources, such as a Filter, a SessionContextListener, a ServletContextListener, or a TagHandler depending on your use case.

Using @WebServiceRef, you can get a reference to a web service and an injection target for it. Items annotated with @WebServiceRef follow the standard rules for resource injection within Java EE 5. It defines five attributes or properties, as are described in Table 6-1.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint