HOW TO CREATE WSDL FILE IN APACHE CXF :
ApacheCxf project Explorer:
ApacheCxf project Explorer:
PROCEDURE TO CREATE WSDL FILE WITH APACHE CXF :
1) CREATE A NEW MAVEN PROJECT.
2) NOW SELECT CATALOG - INTERNAL AND SELECT MAVEN ARCHETYPE QUICK START AND CLICK ON NEXT.
3) GIVE GROUP ID & ARCHETYPE ID AND FINISH.
4) NOW ADD DEPENDENCIES IN POM.XML FILE
i) cxf-rt-frontend-jaxws
ii) cxf-rt-transports-http
iii) spring-webmvc
iv) javax.servlet-api
5) NOW ADD CODE GEN PLUGIN INSIDE PLUGINS TAG OF BUILD TAG.
cxf-codegen-plugin
6) NOW UPDATE MAVEN PROJECT.
xyz.wsdl :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://info.revanth.wsdl/xyz/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="xyz" targetNamespace="http://info.revanth.wsdl/xyz/">
<wsdl:types>
<xsd:schema targetNamespace="http://info.revanth.wsdl/xyz/">
<xsd:element name="additionRequest" type="tns:additionRequestType"/>
<xsd:element name="additionResponse" type="tns:additionResponseType"/>
<xsd:complexType name="additionRequestType">
<xsd:sequence>
<xsd:element name="fno" type="xsd:integer"/>
<xsd:element name="sno" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="additionResponseType">
<xsd:sequence>
<xsd:element name="result" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="addition">
<wsdl:part element="tns:additionRequest" name="parameters"/>
</wsdl:message>
<wsdl:message name="additionResponse">
<wsdl:part element="tns:additionResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="xyz">
<wsdl:operation name="addition">
<wsdl:input message="tns:addition"/>
<wsdl:output message="tns:additionResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="xyzSOAP" type="tns:xyz">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="addition">
<soap:operation soapAction="http://info.revanth.wsdl/xyz/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OperationsServices">
<wsdl:port binding="tns:xyzSOAP" name="xyzSOAP">
<soap:address location="http://localhost:9002/Cxf/demo"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>info.inetsolv</groupId>
<artifactId>contractfirst</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>contractfirst Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>contractfirst</finalName>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/xyz.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
No comments:
Post a Comment