Skip to content

Commit

Permalink
Add Oppdrag web service client and update configurations
Browse files Browse the repository at this point in the history
Added new OppdragClient class, related configuration, and corresponding consumer and controller. Adjusted build configurations and dependencies for SOAP-based web service compatibility. Replaced reactive-core with
  • Loading branch information
krharum committed May 28, 2024
1 parent 8732b81 commit 35be286
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 10 deletions.
19 changes: 16 additions & 3 deletions apps/oppdrag-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ wsimport {
generatedSourceRoot = "/generated/src/wsdl/main"
generatedClassesRoot = "/classes/main"
wsdl("oppdragServiceWSBinding.wsdl") {
packageName = "no.nav.testnav.oppdrag.service"
packageName = "no.nav.testnav.oppdragservice.wsdl"
xjcarg("-XautoNameResolution")
}
verbose = true
Expand Down Expand Up @@ -79,13 +79,23 @@ repositories {
}
}

configurations {
jaxws
}

dependencies {
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.0'

jaxws 'com.sun.xml.ws:jaxws-tools:3.0.0',
'jakarta.xml.ws:jakarta.xml.ws-api:3.0.0',
'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0',
'jakarta.activation:jakarta.activation-api:2.0.0',
'com.sun.xml.ws:jaxws-rt:3.0.0'

implementation 'no.nav.testnav.libs:security-core'
implementation 'no.nav.testnav.libs:reactive-core'
implementation 'no.nav.testnav.libs:reactive-security'
implementation 'no.nav.testnav.libs:servlet-core'
implementation 'no.nav.testnav.libs:servlet-security'
implementation 'no.nav.testnav.libs:data-transfer-objects'

implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
Expand All @@ -97,6 +107,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.ws:spring-ws-security'

implementation 'ma.glasnost.orika:orika-core:1.5.4'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
4 changes: 2 additions & 2 deletions apps/oppdrag-service/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
rootProject.name = 'oppdrag-service'

includeBuild '../../libs/security-core'
includeBuild '../../libs/reactive-core'
includeBuild '../../libs/reactive-security'
includeBuild '../../libs/servlet-core'
includeBuild '../../libs/servlet-security'
includeBuild '../../libs/data-transfer-objects'

gradleEnterprise {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package no.nav.testnav.oppdrag.service.config;

import no.nav.testnav.libs.reactivecore.config.CoreConfig;
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
import no.nav.testnav.libs.servletcore.config.ApplicationCoreConfig;
import no.nav.testnav.libs.servletsecurity.config.SecureOAuth2ServerToServerConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import({
CoreConfig.class,
ApplicationCoreConfig.class,
SecureOAuth2ServerToServerConfiguration.class
})
public class ApplicationConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import no.nav.testnav.libs.reactivecore.config.ApplicationProperties;
import no.nav.testnav.libs.servletcore.config.ApplicationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package no.nav.testnav.oppdrag.service.config;

import no.nav.testnav.oppdrag.service.consumer.OppdragClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.ws.config.annotation.EnableWs;

@EnableWs
@Configuration
public class OppdragWsConfiguration {

@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
// this package must match the package in the <generatePackage> specified in
// pom.xml
marshaller.setContextPath("no.nav.testnav.oppdragservice.wsdl");
return marshaller;
}

@Bean
public OppdragClient countryClient(Jaxb2Marshaller marshaller) {

var client = new OppdragClient();
client.setDefaultUri("http://localhost:8080/ws");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package no.nav.testnav.oppdrag.service.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.soap.client.core.SoapActionCallback;

@Slf4j
public class OppdragClient extends WebServiceGatewaySupport {

public OppdragClient postOppdrag(String country) {

// GetCountryRequest request = new GetCountryRequest();
// request.setName(country);
//
// log.info("Requesting location for " + country);
//
// GetCountryResponse response = (GetCountryResponse) getWebServiceTemplate()
// .marshalSendAndReceive("http://localhost:8080/ws/countries", request,
// new SoapActionCallback(
// "http://spring.io/guides/gs-producing-web-service/GetCountryRequest"));
//
// return response;
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package no.nav.testnav.oppdrag.service.consumer;

import org.springframework.stereotype.Service;

@Service
public class OppdragConsumer {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package no.nav.testnav.oppdrag.service.provider;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/oppdrag")
public class OppdragController {

@PostMapping
public void sendOppdrag() {}
}
2 changes: 1 addition & 1 deletion apps/oppdrag-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ spring:
banner-mode: off
application:
name: testnav-oppdrag-service
description: App for å sjekke hvilke miljøer i test og preprod som er tilgjengelige nå.
description: App for å sende oppdrag til Oppdragssystemet.
security:
oauth2:
resourceserver:
Expand Down

0 comments on commit 35be286

Please sign in to comment.