Oracle® SOA Suite Developer's Guide 10g (10.1.3.1.0) Part Number B28764-01 |
|
|
View PDF |
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); }