- Language:
Java 17 (LTS)
- Built with:
Maven
,Spring Boot
- In-Memory Database:
H2
- Configuration file: application.properties
- Endpoint: http://localhost:8080/soap-demo
- com.example.soap.example
-
class SoapExampleApplication
-
- @interface YerbaMateExample
-
- class MappingConfig
- class WebServiceConfig
-
- class YerbaMateEndpoint
-
- class YerbaMateEntity
-
- interface YerbaMateRepository
-
- enum Country
- class GetYerbaMateRequest
- class GetYerbaMateResponse
- class ObjectFactory
- package-info
- class YerbaMate
- enum YerbaMateType
-
- interface YerbaMateService
- class YerbaMateServiceImpl
-
- class YerbaMateConverter
- class YerbaMateExampleProcessor
- class YerbaMateFactory
-
-
Annotation
- YerbaMateExample - Custom annotation to annotate method that returns instance of YerbaMate.
-
Configuration layer
-
MappingConfig - Bean declaration of ModelMapper.
-
WebServiceConfig - Configuration of Web Service.
-
-
Endpoint
- YerbaMateEndpoint - Web Service Endpoint declaration.
-
Entity
- YerbaMateEntity - Entity representation of YerbaMate.
-
Repository layer
- YerbaMateRepository - JPA Repository of YerbaMateEntity.
-
Schema
- Country - Enum of countries of origins of Yerba maté.
- GetYerbaMateRequest - Anonymous complex type definition.
- GetYerbaMateResponse - Anonymous complex type definition.
- ObjectFactory - Produces instances of Java representation of XML content.
- YerbaMate - DTO representation of Yerba maté.
- YerbaMateType - Enum of produced types of Yerba maté.
-
Service layer
- YerbaMateService - YerbaMate Service definition.
- YerbaMateServiceImpl - YerbaMate Service implementation - business logic.
-
Utils
- YerbaMateConvert - Map DTOs and entities to each other using ModelMapper.
- YerbaMateExampleProcessor - Process usage of YerbaMateExample annotation with
Java Reflections
. - YerbaMateFactory - Produces prebuilt instances of YerbaMate.
File yerba-mate.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://localhost:8080/soap-demo"
targetNamespace="http://localhost:8080/soap-demo"
elementFormDefault="qualified">
<xs:element name="getYerbaMateRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="brand" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getYerbaMateResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="yerbaMate" type="tns:yerbaMate"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- PAYLOAD -->
<xs:complexType name="yerbaMate">
<xs:sequence>
<xs:element name="brand" type="xs:string"/>
<xs:element name="origin" type="tns:country"/>
<xs:element name="type" type="tns:yerbaMateType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="country">
<xs:restriction base="xs:string">
<xs:enumeration value="Argentina"/>
<xs:enumeration value="Brazil"/>
<xs:enumeration value="Paraguay"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="yerbaMateType">
<xs:restriction base="xs:string">
<xs:enumeration value="elaborada"/>
<xs:enumeration value="despalada"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
File request-example.xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:std="http://localhost:8080/soap-demo">
<soapenv:Header/>
<soapenv:Body>
<std:getYerbaMateRequest>
<std:brand>Pajarito Classic</std:brand>
</std:getYerbaMateRequest>
</soapenv:Body>
</soapenv:Envelope>
Send request using curl
:
curl --location 'http://localhost:8080/soap-demo' --header 'Content-Type: text/xml' --data @./src/main/resources/request-example.xml
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:getYerbaMateResponse xmlns:ns2="http://localhost:8080/soap-demo">
<ns2:yerbaMate>
<ns2:brand>Pajarito Classic</ns2:brand>
<ns2:origin>Paraguay</ns2:origin>
<ns2:type>elaborada</ns2:type>
</ns2:yerbaMate>
</ns2:getYerbaMateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
ArtifactId | Version |
---|---|
Spring Boot Starter | 3.2.0 |
Spring Boot Starter Data JPA | 3.2.0 |
Spring Boot Starter Web Services | 3.2.0 |
WSDL4J | 1.6.3 |
Jaxb-API | 2.3.1 |
H2 | 2.2.224 |
ModelMapper | 3.2.0 |
Lombok | 1.18.30 |