0

I did a REST wrapper for some SOAP services. Now I want to add HATEOAS support but, for the resources I use the auto created classes with the maven-jaxb2-plugin library. For example the auto generated class BookDetails:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BookDetails", propOrder = {
     "id",
     "name",
     "title",
     "author"
})
public class BookDetails {

    @XmlElement(required = true)
    protected String id;>

  ...
}

I cannot extend that class from ResourceSupport because if the .wsdl change the BookDetails class is recreated and overwrite. Also if a created a new class that extends from BookDetails like BookDetailsResource then I cannot extend from ResourceSupport. Any idea or previous problem similar?

Here is a tutorial on how to create the wrapper if someone needs to implement it. https://howtodoinjava.com/spring/spring-boot/spring-soap-client-webservicetemplate/

Banana
  • 2,435
  • 7
  • 34
  • 60

1 Answers1

0

Instead of trying to create one domain model to map onto both, it's probably better to have separate domain models for SOAP and for HAL.

This way, you can use Spring Web Services deploy its contract-first approach and generate WSDL-based BookDetails domain objects.

From there you can define your REST controller and it's various methods to GET/POST/PUT, etc.

The final step would be to define a ResourceAssembler<BookDetails, Resource<BookDetails>> that leverages your REST controller, and ends up converting SOAP-based BookDetails objects into a HAL representation that includes relevant links.

Check out https://spring.io/guides/tutorials/rest/ to see how to structure the REST part of your app, and then think of the SOAP calls as being an underlying service layer your REST controller can invoke.

gregturn
  • 2,625
  • 3
  • 25
  • 40