Hello
I have to produce documentation for my team. This documentation should show how to generate a webservice project from scratch, compile it and deploy it.
To realize this project, I wrote a simple project whose main files are :
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inrae.sicpa</groupId>
<artifactId>MyServiceWS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>MyServiceWS</name>
<!-- FIXME change it to the project's website -->
<properties>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.jws</groupId>
<artifactId>jakarta.jws-api</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>jakarta.xml.soap</groupId>
<artifactId>jakarta.xml.soap-api</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
<build>
<finalName>MyServiceWS</finalName>
<directory>${basedir}/target</directory>
<!-- main -->
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<!-- test -->
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
<include>*.xml</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>${basedir}/src/main/webapp/WebContent</warSourceDirectory>
<warSourceExcludes>${basedir}/src/main/webapp/WEB-INF/web.xml</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<display-name>MyServiceWS</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
src/main/webapp/WEB-INF/payara-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE payara-web-app PUBLIC
"-//Payara.fish//DTD Payara Server 4 Servlet 3.0//EN"
<payara-web-app>
<context-root>/MyServiceWS</context-root>
</payara-web-app>
/src/main/java/fr/inrae/sicpa/services/IMyService.java
package fr.inrae.sicpa.services;
import javax.jws.WebService;
public interface IMyService
{
public double getPrixTTC( double ht );
public double getPrixHT( double ttc );
public double getTVA( double prix, boolean isTTC );
}
/src/main/java/fr/inrae/sicpa/services/MyServiceImpl.java
package fr.inrae.sicpa.services;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
@WebService(serviceName="MyServiceWS", portName="MyServicePort", endpointInterface="fr.inrae.sicpa.MyServiceWS")
@SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL)
public class MyServiceImpl implements IMyService
{
private final static double TAUX = 0.196;
@WebMethod(operationName="getPrixTTC")
@WebResult(name = "ttc")
@Override
public double getPrixTTC(double ht)
{
return ht * (1 + TAUX);
}
@WebMethod(operationName="getPrixHT")
@WebResult(name = "ht")
@Override
public double getPrixHT(double ttc)
{
return ttc / (1 + TAUX);
}
@WebMethod(operationName="getTVA")
@WebResult(name = "tva")
@Override
public double getTVA(double prix, boolean isTTC)
{
if(isTTC)
return prix - (prix/(1 + TAUX));
else
return prix * TAUX;
}
}
At this stage, I manage to generate my project structure, compile the project and deploy it on my payara server (5.192). But what I don't understand is that neither the wsdl file nor the endpoint are created at deployment time.
I've been struggling with this since the end of December. Where do you think my error lies?
Thank you very much for your help
Thierry