Skip Headers
Oracle® SOA Suite Developer's Guide
10g (10.1.3.1.0)

Part Number B28764-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

4.6 Exposing a Session Bean as a Web Service

Exposing a session bean as a web service is fairly straightforward and most of the steps are automated when you use JDeveloper's wizards and dialogs. When you generate a web service endpoint interface for a session bean (Section 4.4.1, "How to Create a Session Bean") the JSR-181 web services library is automatically added to your project and the @WebService annotation is added to your session bean. When you create methods using the Bean Methods Details dialog (Section 4.4.5, "How to Add New Methods to the Session Bean"), the appropriate annotations are added if you select Expose through Web Service Endpoint interface.

However, if you have an existing session bean or want to code the methods manually, you may do so. Following is the CustomerService.java file that shows the web services annotations.

Example 4-10 CustomerService.java with web service annotations

package org.soademo.customerservice.business;
 
import java.rmi.RemoteException;
 
import javax.ejb.Remote;
 
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
 
import org.soademo.customerservice.persistence.Customer;
 
@WebService(serviceName = "CustomerSvc",
            targetNamespace = "http://www.globalcompany.com/ns/customer")
public interface CustomerService {
 
    @WebMethod
    Customer findCustomerById(
           @WebParam(name = "custid", 
                     targetNamespace = "http://www.globalcompany.com/ns/customer")
                String custid) throws RemoteException;
 
    @WebMethod
    String getCustomerStatus(
           @WebParam(name = "CustomerID", 
                     targetNamespace = "http://www.globalcompany.com/ns/customer")
                String CustomerID);
 
    @WebMethod
    String addNewCustomer(
           @WebParam(name = "customer", 
                     targetNamespace = "http://www.globalcompany.com/ns/customer")
                Customer customer);
 
    @WebMethod
    Customer findCustomerByEmail(
           @WebParam(name = "email", 
                     targetNamespace = "http://www.globalcompany.com/ns/customer")
                String email, 
           @WebParam(name = "password",
                     targetNamespace = "http://www.globalcompany.com/ns/customer")
                String password);
}