The Maven project structure is shown below
1. Create domain class(UserDetails.java)
package com.spring.domain;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class UserDetails {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getBankBalance() {
return bankBalance;
}
public void setBankBalance(BigDecimal bankBalance) {
this.bankBalance = bankBalance;
}
private BigDecimal bankBalance;
}
2. Create webservice interface (IBankAccountService.java)
package com.spring.webservice;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.spring.domain.UserDetails;
@WebService
public interface IBankAccountService {
public UserDetails getUserDetails(@WebParam(name="userName") final String userName);
public void addUserDetail(@WebParam(name="userDetails") final UserDetails userDetails);
}
3. Add Maven dependency
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd" >
<modelVersion>4.0.0</modelVersion>
<groupId>SpringWsdlGenerator</groupId>
<artifactId>SpringWsdlGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringWsdlGenerator</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>3.0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-test-sources</id>
<phase>generate-test-sources</phase>
<configuration>
<className>com.spring.webservice.IBankAccountService</className>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.1-b16</version>
</dependency>
</dependencies>
</project>
4. Run the maven build
output
SpringWsdlGenerator\target\generated\wsdl\IBankAccountService.wsdl
1. Create domain class(UserDetails.java)
package com.spring.domain;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD)
public class UserDetails {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getBankBalance() {
return bankBalance;
}
public void setBankBalance(BigDecimal bankBalance) {
this.bankBalance = bankBalance;
}
private BigDecimal bankBalance;
}
2. Create webservice interface (IBankAccountService.java)
package com.spring.webservice;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.spring.domain.UserDetails;
@WebService
public interface IBankAccountService {
public UserDetails getUserDetails(@WebParam(name="userName") final String userName);
public void addUserDetail(@WebParam(name="userDetails") final UserDetails userDetails);
}
3. Add Maven dependency
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd" >
<modelVersion>4.0.0</modelVersion>
<groupId>SpringWsdlGenerator</groupId>
<artifactId>SpringWsdlGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringWsdlGenerator</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>3.0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-test-sources</id>
<phase>generate-test-sources</phase>
<configuration>
<className>com.spring.webservice.IBankAccountService</className>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.1-b16</version>
</dependency>
</dependencies>
</project>
4. Run the maven build
output
SpringWsdlGenerator\target\generated\wsdl\IBankAccountService.wsdl
No comments:
Post a Comment