Generate web service client stub class by using the JAXWS maven plugin.
"jaxws-maven-plugin" will generate the web service stub classes by using that we can implement client or test the web service.
generated stub classes will stored under src folder and by using this service classes we can communicate with service and get the response.
for free webservice for the learning and client implementation visit xmethod.com
take any service and generate the client stub classes.
add the WSDL URL in the pom.xml
full sample :
"jaxws-maven-plugin" will generate the web service stub classes by using that we can implement client or test the web service.
generated stub classes will stored under src folder and by using this service classes we can communicate with service and get the response.
for free webservice for the learning and client implementation visit xmethod.com
take any service and generate the client stub classes.
add the WSDL URL in the pom.xml
<wsdlUrls> <wsdlUrl> enter the wsdl URL here </wsdlUrl> </wsdlUrls>
full sample :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<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>com.uttesh</groupId> | |
<artifactId>wsclient</artifactId> | |
<version>1.0.0</version> | |
<packaging>jar</packaging> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>1.7</maven.compiler.source> | |
<maven.compiler.target>1.7</maven.compiler.target> | |
</properties> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>jaxws-maven-plugin</artifactId> | |
<version>1.9</version> | |
<executions> | |
<execution> | |
<goals> | |
<goal>wsimport</goal> | |
</goals> | |
<phase>generate-sources</phase> | |
</execution> | |
</executions> | |
<configuration> | |
<!-- Keep generated files --> | |
<keep>true</keep> | |
<!-- Package name --> | |
<packageName>org.example.echo.service.skeleton</packageName> | |
<!-- generated source files destination--> | |
<sourceDestDir>src/main/java</sourceDestDir> | |
<wsdlUrls> | |
<wsdlUrl> | |
https://ec.europa.eu/taxation_customs/tin/checkTinService.wsdl | |
</wsdlUrl> | |
</wsdlUrls> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.uttesh.wsclient; | |
import javax.xml.datatype.XMLGregorianCalendar; | |
import javax.xml.ws.Holder; | |
import org.example.echo.service.skeleton.CheckTinPortType; | |
import org.example.echo.service.skeleton.CheckTinService; | |
/** | |
* | |
* @author Uttesh Kumar T.H. | |
*/ | |
public class WsTest { | |
public static void main(String[] args) { | |
try { | |
CheckTinService checkTinService = new CheckTinService(); | |
CheckTinPortType portType = checkTinService.getPort(CheckTinPortType.class); | |
Holder<String> code = new Holder<String>("DE"); | |
Holder<String> tin = new Holder<String>("12346789"); | |
Holder<XMLGregorianCalendar> requestDate = new Holder<>(); | |
Holder<Boolean> validStructure = new Holder<>(); | |
Holder<Boolean> validSyntax = new Holder<>(); | |
portType.checkTin(code, tin, requestDate, validStructure, validSyntax); | |
System.out.println("requestDate : " + requestDate.value); | |
System.out.println("validStructure : " + validStructure.value); | |
System.out.println("validSyntax : " + validSyntax.value); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
0 comments:
Post a Comment