EJB3.0 specification has made writing web services much easier. You do not even need a web application to host the service. The web services can be hosted in EJB container in an easy way. To write the web service write a Stateless EJB and mark it as Web service
ProductPriceBean.java
@Stateless
@WebService
public class ProductPriceBean {
private Map productMap = new HashMap();
{
productMap.put("Java","500");
productMap.put("C++","300");
}
@WebMethod
public double getPrice(String symbol){
String price = (String) productMap.get(symbol);
if(price != null){
return Double.parseDouble(price);
}
return -1;
}
Note that you donot have to write any interface like Local or Remote. Just write this, deploy it as a Jar in your EJB container and hit the ((WSDL)) at:
No comments:
Post a Comment