Skip to content

Native web service support was added to Spring Boot Platform #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions gxspringboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
<name>GeneXus Spring Boot</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxclassR</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxclassR</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxwrapperjakarta</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public void onStartup(ServletContext container) {
ServletRegistration.Dynamic dispatcherQuery3 = container.addServlet("gxqueryviewerforsd", (Servlet) Class.forName("qviewer.services.gxqueryviewerforsd").getConstructor().newInstance());
dispatcherQuery3.addMapping("/qviewer.services.gxqueryviewerforsd");
}

try {
Class<?> wsServlet = Class.forName("com.sun.xml.ws.transport.http.servlet.WSServlet");
ServletRegistration.Dynamic dispatcherQuery3 = container.addServlet("JaxWSServlet", (Servlet) wsServlet.getConstructor().newInstance());
dispatcherQuery3.setLoadOnStartup(1);
dispatcherQuery3.addMapping("/servlet/ws/*");
dispatcherQuery3.addMapping("/ws/*");
}
catch (ClassNotFoundException e) {
log.info("Declare servlet mapping for com.sun.xml.ws.transport.http.servlet.WSServlet is not necessary");
}
}
catch(Exception e) {
log.error("Error executing ServletContextInitializer", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.genexus.springboot.jaxws;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebListener;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Logger;
import org.springframework.core.io.ClassPathResource;
import java.io.IOException;

@WebListener
public class GXWSServletContextListener implements ServletContextListener {
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(GXWSServletContextListener.class);
private com.sun.xml.ws.transport.http.servlet.WSServletContextListener listener = null;

public static final String JAXWS_METADATA_FILE = "sun-jaxws.xml";
public static final String JAXWS_METADATA_PATH = "WEB-INF/sun-jaxws.xml";

public GXWSServletContextListener() {
if (new ClassPathResource(JAXWS_METADATA_FILE).exists())
this.listener = new com.sun.xml.ws.transport.http.servlet.WSServletContextListener();
}

@Override
public void contextInitialized(ServletContextEvent sce) {
if (listener != null) {
try {
FileUtils.copyInputStreamToFile(new ClassPathResource(JAXWS_METADATA_FILE).getInputStream(),
new java.io.File(sce.getServletContext().getRealPath("") + JAXWS_METADATA_PATH));
} catch (IOException e) {
log.error(String.format("File %s not found", JAXWS_METADATA_FILE), e);
}

listener.contextInitialized(sce);
}
}

@Override
public void contextDestroyed(ServletContextEvent sce) {
if (listener != null)
listener.contextDestroyed(sce);
}
}