Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To deploy the Converter EJB Service, we are going to create a remote interface and a stateless session bean that implements the interface. The steps required are as follows:

  1. Right-click on ejbModule and select New --> Package




  2. Name the package to org.apache.geronimo.samples.jaxws and click Finish




  3. Right-click on the new package and select New --> Interface




  4. Name the interface as Converter and use the org.apache.geronimo.samples.jaxws package, then click Finish




  5. Add the following code to the Converter class:
    Code Block
    titleConverter.java
    borderStylesolid
    
    package org.apache.geronimo.samples.jaxws;
    
    import java.math.BigDecimal;
    
    import javax.ejb.Remote;
    import javax.jws.WebService;
    
    @Remote
    @WebService(name = "ConverterPortType",
                targetNamespace = "http://jaxws.samples.geronimo.apache.org")
    public interface Converter {
    
    	public BigDecimal dollarToRupees(BigDecimal dollars);
    
    	public BigDecimal rupeesToEuro(BigDecimal rupees);
    }
    
    


  6. Right-click on the new package and select New --> Class




  7. Name the class as ConverterBean and use the org.apache.geronimo.samples.jaxws package, then click Finish




  8. Add the following code to the ConverterBean class:
    Code Block
    titleConverterBean.java
    borderStylesolid
    
    package org.apache.geronimo.samples.jaxws;
    
    import java.math.BigDecimal;
    import javax.ejb.*;
    import javax.jws.WebService;
    
    @Stateless
    @WebService(serviceName = "Converter",
                portName = "ConverterPort",
                endpointInterface = "org.apache.geronimo.samples.jaxws.Converter",
                targetNamespace = "http://jaxws.samples.geronimo.apache.org")
    public class ConverterBean implements Converter {
    	private BigDecimal rupeeRate = new BigDecimal("40.58");
    	private BigDecimal euroRate = new BigDecimal("0.018368");
    
    	public BigDecimal dollarToRupees(BigDecimal dollars) {
    		BigDecimal result = dollars.multiply(rupeeRate);
    		return result.setScale(2, BigDecimal.ROUND_UP);
    	}
    
    	public BigDecimal rupeesToEuro(BigDecimal rupees) {
    		BigDecimal result = rupees.multiply(euroRate);
    		return result.setScale(2, BigDecimal.ROUND_UP);
    	}
    }
    
    

...

Now, we will look into the steps involved in deploying and testing our web service without any clients.

Deploy

  1. Right-click on the Apache Geronimo Server Runtime present in the servers view and select Add or Remove Projects

  2. In the popup dialog, select the jaxws-converterejb project and click Add




  3. Make sure that jaxws-converterejb is in the configured projects list and then click Finish




  4. Wait for some time till the server status is changed to synchronized.
    Info
    titleErrors at Deploy time

    If you see any errors at deploy time like Unable to read WSDL file null, simply ignore them.



...