How to create WSDL web service client using Maven

| By Webner

Maven provides apache cxf plugin to generate web service client.
We have used below code in our pom.xml file to generate java artifact classes (web service client).

There are two ways to generate client code:

Using complete WSDL URL

Using WSDL artifact

1. Using complete WSDL URL

Add plugin to your pom.xml file:

<wsdl>type your wsd url here </wsdl>

sourceRoot is the location where generated classes are placed. We used ${}/generated/cxf location to place our client code.

2. Using WSDL artifact 

It will point to your directory where your web service code is available. In your pom.xml, replace your WSDL options tag with below code:

<groupId>Enter groupId </groupId>
<artifactId>Enter artifactid </artifactId>
<version>specify version here</version>

In this case, it will pick the WSDL available at the specified location inside maven repository and generate client code respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *