Search in sources :

Example 1 with PutMessageRequestMapper

use of no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper in project efm-integrasjonspunkt by felleslosninger.

the class WebsakPutMessageRequestMapperTest method mapFromEphortePutMessageToWebsakPutMessage.

@Test()
public void mapFromEphortePutMessageToWebsakPutMessage() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType websakRequest = mapper.mapFrom(putMessageRequestType).getValue();
    assertFalse(PayloadUtil.isEmpty(websakRequest.getPayload()));
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), writer);
    String xml = writer.toString();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType websakResult = unmarshaller.unmarshal(new StringSource(xml), no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType.class).getValue();
    System.out.println(websakResult.getPayload());
}
Also used : PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) StringWriter(java.io.StringWriter) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) StringSource(org.springframework.xml.transform.StringSource) Test(org.junit.jupiter.api.Test)

Example 2 with PutMessageRequestMapper

use of no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper in project efm-integrasjonspunkt by felleslosninger.

the class WebsakClient method sendEduMelding.

@Override
public PutMessageResponseType sendEduMelding(PutMessageRequestType request) {
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType> websakRequest = new PutMessageRequestMapper().mapFrom(request);
    final WebServiceTemplate template = templateFactory.createTemplate("no.difi.meldingsutveksling.noarkexchange.websak.schema", markerFrom(new PutMessageRequestWrapper(request)));
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageResponseType> response = (JAXBElement) template.marshalSendAndReceive(settings.getEndpointUrl(), websakRequest, new SoapActionCallback(SOAP_ACTION));
    PutMessageResponseType theResponse = new PutMessageResponseType();
    ModelMapper modelMapper = new ModelMapper();
    modelMapper.map(response.getValue(), theResponse);
    setUnmappedValues(response, theResponse);
    return theResponse;
}
Also used : PutMessageResponseType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType) JAXBElement(javax.xml.bind.JAXBElement) PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) ModelMapper(org.modelmapper.ModelMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback)

Example 3 with PutMessageRequestMapper

use of no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper in project efm-integrasjonspunkt by felleslosninger.

the class WebsakPutMessageRequestMapperTest method emptyPayloadEphorteBug.

@Test
public void emptyPayloadEphorteBug() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/EmptyPayload.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    final JAXBElement<no.difi.meldingsutveksling.noarkexchange.websak.schema.PutMessageRequestType> websakPutMessage = mapper.mapFrom(putMessageRequestType);
    assertNotNull(websakPutMessage.getValue().getPayload());
}
Also used : PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper) Test(org.junit.jupiter.api.Test)

Aggregations

PutMessageRequestType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType)3 PutMessageRequestMapper (no.difi.meldingsutveksling.noarkexchange.websak.PutMessageRequestMapper)3 Test (org.junit.jupiter.api.Test)2 StringWriter (java.io.StringWriter)1 JAXBElement (javax.xml.bind.JAXBElement)1 ObjectFactory (no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory)1 PutMessageResponseType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType)1 ModelMapper (org.modelmapper.ModelMapper)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1 SoapActionCallback (org.springframework.ws.soap.client.core.SoapActionCallback)1 StringSource (org.springframework.xml.transform.StringSource)1