diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/helpapp/rest-service/target/maven-archiver/pom.properties b/helpapp/rest-service/target/maven-archiver/pom.properties index d5ea815..2138542 100644 --- a/helpapp/rest-service/target/maven-archiver/pom.properties +++ b/helpapp/rest-service/target/maven-archiver/pom.properties @@ -1,5 +1,3 @@ -#Generated by Maven -#Tue Dec 10 16:22:56 CET 2024 artifactId=rest-service groupId=insa.application.helpapp version=1.0-SNAPSHOT diff --git a/helpapp/rest-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/helpapp/rest-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 3ec4258..ea7a2ce 100644 --- a/helpapp/rest-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/helpapp/rest-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1 +1 @@ -/home/robin/Desktop/helpapp/rest-service/src/main/java/insa/application/helpapp/rest/RestApplication.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/rest-service/src/main/java/insa/application/helpapp/rest/RestApplication.java diff --git a/helpapp/rest-service/target/rest-service-1.0-SNAPSHOT.jar b/helpapp/rest-service/target/rest-service-1.0-SNAPSHOT.jar index a1b0940..c76de09 100644 Binary files a/helpapp/rest-service/target/rest-service-1.0-SNAPSHOT.jar and b/helpapp/rest-service/target/rest-service-1.0-SNAPSHOT.jar differ diff --git a/helpapp/soap-service/pom.xml b/helpapp/soap-service/pom.xml index da398d8..d122e95 100644 --- a/helpapp/soap-service/pom.xml +++ b/helpapp/soap-service/pom.xml @@ -1,40 +1,73 @@ - - - insa.application.helpapp - helpapp - 1.0-SNAPSHOT - - 4.0.0 - soap-service + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.0 + + + com.example + producing-web-service-complete + 0.0.1-SNAPSHOT + producing-web-service-complete + Demo project for Spring Boot - - - - org.springframework.boot - spring-boot-starter-web-services - - + + 17 + - - - - - org.springframework.boot - spring-boot-maven-plugin - 3.1.4 - + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-web-services + + + + wsdl4j + wsdl4j + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.codehaus.mojo + jaxb2-maven-plugin + 3.1.0 + + + xjc + + xjc + + + + + + ${project.basedir}/src/main/resources/countries.xsd + + + + + + - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 21 - 21 - - - - - diff --git a/helpapp/soap-service/src/main/java/.gitignore b/helpapp/soap-service/src/main/java/.gitignore new file mode 100644 index 0000000..5de3989 --- /dev/null +++ b/helpapp/soap-service/src/main/java/.gitignore @@ -0,0 +1 @@ +io diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java new file mode 100644 index 0000000..f14655f --- /dev/null +++ b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java @@ -0,0 +1,31 @@ +package com.example.producingwebservice; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ws.server.endpoint.annotation.Endpoint; +import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import org.springframework.ws.server.endpoint.annotation.RequestPayload; +import org.springframework.ws.server.endpoint.annotation.ResponsePayload; + +import io.spring.guides.gs_producing_web_service.GetCountryRequest; +import io.spring.guides.gs_producing_web_service.GetCountryResponse; + +@Endpoint +public class CountryEndpoint { + private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service"; + + private CountryRepository countryRepository; + + @Autowired + public CountryEndpoint(CountryRepository countryRepository) { + this.countryRepository = countryRepository; + } + + @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest") + @ResponsePayload + public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) { + GetCountryResponse response = new GetCountryResponse(); + response.setCountry(countryRepository.findCountry(request.getName())); + + return response; + } +} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java new file mode 100644 index 0000000..d9e5a89 --- /dev/null +++ b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java @@ -0,0 +1,47 @@ +package com.example.producingwebservice; + +import jakarta.annotation.PostConstruct; +import java.util.HashMap; +import java.util.Map; + +import io.spring.guides.gs_producing_web_service.Country; +import io.spring.guides.gs_producing_web_service.Currency; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +@Component +public class CountryRepository { + private static final Map countries = new HashMap<>(); + + @PostConstruct + public void initData() { + Country spain = new Country(); + spain.setName("Spain"); + spain.setCapital("Madrid"); + spain.setCurrency(Currency.EUR); + spain.setPopulation(46704314); + + countries.put(spain.getName(), spain); + + Country poland = new Country(); + poland.setName("Poland"); + poland.setCapital("Warsaw"); + poland.setCurrency(Currency.PLN); + poland.setPopulation(38186860); + + countries.put(poland.getName(), poland); + + Country uk = new Country(); + uk.setName("United Kingdom"); + uk.setCapital("London"); + uk.setCurrency(Currency.GBP); + uk.setPopulation(63705000); + + countries.put(uk.getName(), uk); + } + + public Country findCountry(String name) { + Assert.notNull(name, "The country's name must not be null"); + return countries.get(name); + } +} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java new file mode 100644 index 0000000..e9308b1 --- /dev/null +++ b/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java @@ -0,0 +1,12 @@ +package com.example.producingwebservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ProducingWebServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(ProducingWebServiceApplication.class, args); + } +} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java new file mode 100644 index 0000000..3379538 --- /dev/null +++ b/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java @@ -0,0 +1,40 @@ +package com.example.producingwebservice; + +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.ws.config.annotation.EnableWs; +import org.springframework.ws.config.annotation.WsConfigurerAdapter; +import org.springframework.ws.transport.http.MessageDispatcherServlet; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.XsdSchema; + +@EnableWs +@Configuration +public class WebServiceConfig extends WsConfigurerAdapter { + @Bean + public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { + MessageDispatcherServlet servlet = new MessageDispatcherServlet(); + servlet.setApplicationContext(applicationContext); + servlet.setTransformWsdlLocations(true); + return new ServletRegistrationBean<>(servlet, "/ws/*"); + } + + @Bean(name = "countries") + public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { + DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); + wsdl11Definition.setPortTypeName("CountriesPort"); + wsdl11Definition.setLocationUri("/ws"); + wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); + wsdl11Definition.setSchema(countriesSchema); + return wsdl11Definition; + } + + @Bean + public XsdSchema countriesSchema() { + return new SimpleXsdSchema(new ClassPathResource("countries.xsd")); + } +} diff --git a/helpapp/soap-service/src/main/java/insa/application/helpapp/soap/SoapApplication.java b/helpapp/soap-service/src/main/java/insa/application/helpapp/soap/SoapApplication.java deleted file mode 100644 index 3abc8e9..0000000 --- a/helpapp/soap-service/src/main/java/insa/application/helpapp/soap/SoapApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package insa.application.helpapp.soap; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SoapApplication { - - public static void main(String[] args) { - SpringApplication.run(SoapApplication.class, args); - } -} diff --git a/helpapp/soap-service/src/main/resources/application.properties b/helpapp/soap-service/src/main/resources/application.properties index 4d360de..e69de29 100644 --- a/helpapp/soap-service/src/main/resources/application.properties +++ b/helpapp/soap-service/src/main/resources/application.properties @@ -1 +0,0 @@ -server.port=8081 diff --git a/helpapp/soap-service/src/main/resources/countries.xsd b/helpapp/soap-service/src/main/resources/countries.xsd new file mode 100644 index 0000000..a893956 --- /dev/null +++ b/helpapp/soap-service/src/main/resources/countries.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java b/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java new file mode 100644 index 0000000..cc030be --- /dev/null +++ b/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2014-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.producingwebservice; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.spring.guides.gs_producing_web_service.GetCountryRequest; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; +import org.springframework.util.ClassUtils; +import org.springframework.ws.client.core.WebServiceTemplate; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class ProducingWebServiceApplicationIntegrationTests { + + private Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + + @LocalServerPort + private int port = 0; + + @BeforeEach + public void init() throws Exception { + marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class)); + marshaller.afterPropertiesSet(); + } + + @Test + public void testSendAndReceive() { + WebServiceTemplate ws = new WebServiceTemplate(marshaller); + GetCountryRequest request = new GetCountryRequest(); + request.setName("Spain"); + + assertThat(ws.marshalSendAndReceive("http://localhost:" + + port + "/ws", request) != null); + } +} diff --git a/helpapp/soap-service/target/classes/application.properties b/helpapp/soap-service/target/classes/application.properties index 4d360de..e69de29 100644 --- a/helpapp/soap-service/target/classes/application.properties +++ b/helpapp/soap-service/target/classes/application.properties @@ -1 +0,0 @@ -server.port=8081 diff --git a/helpapp/soap-service/target/classes/insa/application/helpapp/soap/SoapApplication.class b/helpapp/soap-service/target/classes/insa/application/helpapp/soap/SoapApplication.class deleted file mode 100644 index e398bf1..0000000 Binary files a/helpapp/soap-service/target/classes/insa/application/helpapp/soap/SoapApplication.class and /dev/null differ diff --git a/helpapp/soap-service/target/maven-archiver/pom.properties b/helpapp/soap-service/target/maven-archiver/pom.properties index fb4a77b..32e12e4 100644 --- a/helpapp/soap-service/target/maven-archiver/pom.properties +++ b/helpapp/soap-service/target/maven-archiver/pom.properties @@ -1,5 +1,3 @@ -#Generated by Maven -#Tue Dec 10 16:22:57 CET 2024 -artifactId=soap-service -groupId=insa.application.helpapp -version=1.0-SNAPSHOT +artifactId=producing-web-service-complete +groupId=com.example +version=0.0.1-SNAPSHOT diff --git a/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index b329ba7..c7ccf0b 100644 --- a/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1 +1,10 @@ -insa/application/helpapp/soap/SoapApplication.class +com/example/producingwebservice/ProducingWebServiceApplication.class +com/example/producingwebservice/WebServiceConfig.class +com/example/producingwebservice/CountryRepository.class +io/spring/guides/gs_producing_web_service/GetCountryResponse.class +io/spring/guides/gs_producing_web_service/package-info.class +com/example/producingwebservice/CountryEndpoint.class +io/spring/guides/gs_producing_web_service/GetCountryRequest.class +io/spring/guides/gs_producing_web_service/ObjectFactory.class +io/spring/guides/gs_producing_web_service/Currency.class +io/spring/guides/gs_producing_web_service/Country.class diff --git a/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index d3b222d..0fcd3a3 100644 --- a/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/helpapp/soap-service/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1 +1,10 @@ -/home/robin/Desktop/helpapp/soap-service/src/main/java/insa/application/helpapp/soap/SoapApplication.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/Country.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/Currency.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/GetCountryRequest.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/GetCountryResponse.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/ObjectFactory.java +/home/yoboujon/Documents/GEI/service-architecture/helpapp/soap-service/target/generated-sources/jaxb/io/spring/guides/gs_producing_web_service/package-info.java diff --git a/helpapp/soap-service/target/soap-service-1.0-SNAPSHOT.jar b/helpapp/soap-service/target/soap-service-1.0-SNAPSHOT.jar deleted file mode 100644 index 2c2b1e3..0000000 Binary files a/helpapp/soap-service/target/soap-service-1.0-SNAPSHOT.jar and /dev/null differ