I have been trying to consume a simple web service crated with GeneXus, it should receive a "nPais" variable (integer) and respond an object with the text property based on the given number. It just doesn't work. I have confirm that the service work by testing it with soapUI (adding the WSDL), but when trying to consume it with postman it responds the correct structure, but with the text property empty.
This is my source tab from the WS.
&sdtServicio = New()
&Servicio.SetEmpty()
Do Case
Case &nPais = 1
&sdtServicio.Texto = "Hola México"
Case &nPais = 2
&sdtServicio.Texto = "Hola Argentina"
Otherwise
&sdtServicio.Texto = "HOLA MUNDO"
Endcase
This is on rules tab
Parm(in:&nPais, out:&sdtServicio);
And here is how I have been trying to consume the service on JS.
function getGreeting(value) {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "GX_CLIENT_ID=54f383cc-0719-444d-a252-c8799c1202a0");
var raw = JSON.stringify({
"nPais": 1
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:8080/PotentorDesaPotDesa/rest/WSHolaMundo", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
This is the response I get.
{"sdtServicio":{"Texto":""}}
The trick was only to change the protocol from SOAP to internal on the properties of my object.