eugenp / tutorials

Just Announced - "Learn Spring Security OAuth":

Home Page:http://bit.ly/github-lsso

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ISSUE] spring-soap Endopint Doesn't Import Generated Objects From jaxb2-maven-plugin

michellemillerh opened this issue · comments

Article and Module Links
https://www.baeldung.com/spring-boot-soap-web-service
https://github.com/eugenp/tutorials/tree/master/spring-soap

Describe the Issue
The tutorial indicates using jaxb2-maven-plugin to generate the models for a SOAP endpoint. But the objects generated by this plugin aren't imported. The existing Endpoint class imports client objects generated off a WSDL file by a different plugin, maven-jaxb-plugin, for the SOAP Client article.

On the current Spring 3 version of the repository, all that needs to be corrected is changing the import path.

Endpoint imports from maven-jaxb2-plugin generation:

import com.baeldung.springsoap.client.gen.GetCountryRequest;

Spring 2 Issues On Older Versions
For reference in case it helps anyone, prior versions of the spring-soap repo, from the time of the Java 17 upgrade until the repo was upgraded to Spring 3, used pom dependencies that result in Jakarta XML annotations on the generated classes. This is masked by the issue explained above, so the generated classes aren't even used. But if you import the XSD generated models instead, and try to use them in an Endpoint class as detailed by the tutorial, the test request in the tutorial will get an error response that says: No adapter for endpoint ... Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?

If you're trying to get a SOAP Endpoint to work with Spring 2 and run into the issue above, you can fix this by removing the jakarta.xml.bind and org.glassfish.jaxb dependencies, and then changing the jaxb2-maven-plugin version to 2.5.0.

To Reproduce
Steps to reproduce the behavior:

  1. Follow link above. Note that the import path includes .client.

Expected Behavior
Remove .client from import path, to use XSD generated models instead of WSDL generated models.

Environment (please complete the following information):

  • OS: macOS Sonoma 14.4.1

Additional Context
The "No adapter for endpoint" error listed seems commonly associated on Stack Overflow with not generating an @XmlRootElement annotation. However, I see this annotation in the generated classes. The actual issue pre-Spring-3 was the generated classes using Jakarta vs JavaX imports.