Versions Compared

Key

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

...

  1. In Project Explorer view, expand jaxws-converter project, right click on Java Resources: src 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 click Finish
  5. Add the following code to the Converter class interface
    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. 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);
    	}
    }
    
    

...

  1. Expand WEB-INF directory and add the following code to web.xml
    Code Block
    xml
    xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://java.sun.com/xml/ns/javaee"
    	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	id="WebApp_ID" version="2.5">
    	<display-name>Converter<name>jaxws-converter</display-name>
    	<servlet>
    		<display-name>Converter</display-name>
    		<servlet-name>Converter</servlet-name>
    		<servlet-class>
    			org.apache.geronimo.samples.jaxws.ConverterService
    		</servlet-class>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>Converter</servlet-name>
    		<url-pattern>/converter</url-pattern>
    	</servlet-mapping>
    
    </web-app>
    
    

...

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

Deploy

  1. Right In Servers view, right click on the Apache Geronimo Server Runtime present in the servers view and select Add or and Remove Projects
    Image Removed
  2. In the popup dialog, select the jaxws-converter project and , click Add
    Image Removed
    Make sure that jaxws-converter is in the configured projects list and then click Finish
    Image Removed
  3. Wait for some time till the server status is changed to synchronized.

...

Using Web Services Explorer in Eclipse

  1. Go to Eclipse and select Run->Launch the Web Services Explorer from the main menu. Image Removed
  2. Web Services Explorer opens up as shown below:


    Image Added


  3. On the top right corner of this explorer, click on the icon for "WSDL Page". Under Navigation section, you will now see WSDL Main. Click that WSDL Main Click the WSDL icon to go to the WSDL main page.
    Image Removed
    Click the WSDL main link to enter the URL of WSDL document.





  4. Enter the URL of our WSDL document i.e http://localhost:8080/jaxws-converter/converter?wsdl in the form and click Go
    Image Removed
    . Now you can see the methods that are exposed by our Web Service.





  5. Clicking on any method takes us to a page with form asking for input parameters.If you dont see any field to enter input arguments click Add.





  6. Enter any argument and examine the status frame at the bottom to see the result.





...