How to create a SOAP client using java, maven and eclipse


In this tutorial we will see how to create a java soap client using maven and eclipse. You can adapt with your configuration if you are using other tools.

For the example, we will use the AWSECommerceService SOAP service from Amazon. you may need additional keys generated from Amazon’s website to make the example work. The WSDL is available at :

1- Create a new project

Create a new maven project using the maven-archetype-quickstart.


2 – Download the WSDL

Download and put the the wsdl file in src/main/resources . You may have to create the folder if it does not exist.

project structure

3- Add maven dependencies and plugins

Open the pom.xml file and add the maven-compiler-plugin and the cxf-codegen-plugin as follows:


In the dependencies section add the following dependencies :


4- Generate the classes using CXF codegen plugin

To generate the classes using eclipse Do a right click on the project then click on  Run as > Maven generate resources. This will be generate the required classes under src/generated. You may have to add the new generated folder into eclipse build path, but it’s not necessary to execute the maven build.

5- Consume the SOAP service

Final step is to use the generated classes in order to consume the service like in the following example :

package com.tutoref.soapclient;



public class App{
 public static void main( String[] args ){
  try {
   // instantiate the client !! 
   // this is only an example, to make the code work you may need to generate keys
   // Documentation is available on Amazon's website
   URL url = new URL("");
   AWSECommerceService service = new AWSECommerceService(url);
   AWSECommerceServicePortType port = service.getAWSECommerceServicePortCA();

   // prepare the search criteria
   ItemSearch itemSearch = new ItemSearch();

   // invoke the search action
   ItemSearchResponse itemSearchResponse = port.itemSearch(itemSearch);

   // .. Do whatever what you do with the response ...

  } catch (MalformedURLException e) {