I am trying to consume a soap service with java and spring also maven-jaxb2-plugin.
this is my controller
import java.sql.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.consumingwebservice.wsdl.TransferenciaDocumentos;
import com.example.consumingwebservice.wsdl.TransferenciaDocumentosRequest;
import com.example.consumingwebservice.wsdl.TransferenciaDocumentosResponse;
import client.TransferenciaDocumentosClient;
@SpringBootApplication
@RestController
public class AzurianWsApplication {
@Autowired
private TransferenciaDocumentosClient client;
@GetMapping("/getDocumentos")
public TransferenciaDocumentosResponse invokeDocumentosResponse () {
TransferenciaDocumentos documentos = new TransferenciaDocumentos();
TransferenciaDocumentosRequest request = new TransferenciaDocumentosRequest();
request.setFechaDesde(Date.valueOf("2021-10-01"));
request.setFechaDesde(Date.valueOf("2021-12-31"));
request.setNroResolucion(0);
request.setRutEmpresa(7656066);
request.setWsApiKey("60fa6eb48c91c4e704a4d9c22c19ee");
documentos.setRequest(request);
return client.transferenciaDocumentosResponse(documentos);
}
public static void main(String[] args) {
SpringApplication.run(AzurianWsApplication.class, args);
}
}
when I make the request with the sample data it returns null, instead if I do the same test in SoapUi this one does return data, I leave the client class below.
package cl.nobelti.grupogtd.azuriantoax.client;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import com.example.consumingwebservice.wsdl.TransferenciaDocumentos;
import com.example.consumingwebservice.wsdl.TransferenciaDocumentosResponse;
public class TransferenciaDocumentosClient extends WebServiceGatewaySupport{
public TransferenciaDocumentosResponse transferenciaDocumentosResponse(TransferenciaDocumentos request) {
TransferenciaDocumentosResponse response = (TransferenciaDocumentosResponse) getWebServiceTemplate()
.marshalSendAndReceive("http://soa.group.com:7503/serviciorecepcion?wsdl", request);
return response;
}
}
I am using the spring guide to do this, I attach it in case you want to see it:
https://spring.io/guides/gs/consuming-web-service/
my response looks something like this:
"transferenciaDocumentosReturn": {
"codigoRespuesta": null,
"descripcion": null,
"documentos": null
}
}
I think the request is not coming but it prints it and it really is there, please help!