Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

  1. In Project Explorer view, expand jaxws-converter project, right-click on Java Resources: src and select New --> Package.

  2. Specify org.apache.geronimo.samples.jaxws as the package name 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 interface:
    Code Block
    borderStylesolid
    titleConverter.javaborderStylesolid
    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);
    }
    
  6. Right-click on the new package and select New --> Class.

  7. Name the class as ConverterService, add org.apache.geronimo.samples.jaxws.Converter as the interface and click Finish.

  8. Add the following code to the ConverterService class:
    Code Block
    borderStylesolid
    titleConverterService.javaborderStylesolid
    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);
    	}
    }
    
  9. Let us try to understand each annotation:

...