Versions Compared

Key

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

...

  1. Create a Dynamic Web Project
    • Select File->New->Other
    • In the popup window, Select Web->Dynamic Web Project and click Next
    • Type jaxws-converter as the Project Name and click Next
    • The default options should work in the case of Geronimo as it On the Project Facets page, the default selections (as shown below) are enough as Geronimo has axis2 web container already running, click Next





    • Make sure that the check box Generate Deployment Descriptor is selected and click Next
    • Modify On the Geronimo Deployment Page modify the Group Id to org.apache.geronimo.samples.jaxws and the artifact id to jaxws-converter. Image Removed
    • Click Finish

This completes the configuration of Eclipse for application development.

...

To deploy the Converter service we are going to create a POJO interface and a class and expose it as a servlet. The steps required are:

  1. Right In Project Explorer view, expand jaxws-converter project, right click on JavaRsourcesJava Resources: src and select New->Package
    Image Removed
  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 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.jws.WebService;
    
    @WebService(name="ConverterPortType",
            targetNamespace = "http://jaxws.samples.geronimo.apache.org")
    public interface Converter {
    	
    	public BigDecimal dollarToRupees(BigDecimal dollars);
    	public BigDecimal rupeesToEuro(BigDecimal rupees);
    
    }
    
    
  1. Right In Project Explorer view, right click on the new package and select New->Class
  2. Name the class as ConverterService, add org.apache.geronimo.samples.jaxws.Converter as Interface and click Finish
  3. Add the following code to the ConverterService class
    Code Block
    titleConverterService.java
    borderStylesolid
    
    package org.apache.geronimo.samples.jaxws;
    
    import java.math.BigDecimal;
    
    import javax.jws.WebService;
    
    @WebService(serviceName = "Converter",
            portName="ConverterPort",
            endpointInterface = "org.apache.geronimo.samples.jaxws.Converter",
            targetNamespace = "http://jaxws.samples.geronimo.apache.org"
            )
    public class ConverterService  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);
    	}
    }
    
    

...