My first question is: Can I call the WebService directly via JQUERY / AJAX or do I need to have something in PHP or some other backend language to perform the integration?
If it is possible only with JQUERY / AJAX , it follows the problem.
I have the following WebService :
http://IP:PORTA/wsexecbo/WebServiceExecBO?wsdl
In this WebService I have the following function:
http://IP:PORTA/wsexecbo/WebServiceExecBO?wsdl/userLogin
I send a user (no password) and it returns me a token.
Follow my custom.js :
$(document).ready(function() {
var soapMessage =
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" +
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://service.execbo.ws.framework.totvs.com'>" +
"<soapenv:Header/>" +
"<soapenv:Body>" +
"<ser:userLogin>" +
"<arg0>user</arg0>" +
"</ser:userLogin>" +
"</soapenv:Body>" +
"</soapenv:Envelope>";
var wsUrl = "http://IP:PORTA/wsexecbo/WebServiceExecBO?wsdl/userLogin";
$.ajax({
type: "POST",
dataType: "xml",
url: wsUrl,
data: soapMessage,
success: function(data) {
console.log(data);
},
error: function(error) {
console.log(error);
}
});
});
But it always returns this:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header>
</env:Header>
<env:Body>
<env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<faultcode>env:Server</faultcode>
<faultstring>
Unsupported content type: application/x-www-form-urlencoded; charset=UTF-8
</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
I made some tests by putting these options:
contentType: "text/xml"
contentType: "application/xml"
But nothing solves it. Would anyone know what's going on and how can I resolve this?