Estou tendo um problema ao tentar pegar o retorno do WebService.
Utilizei essa documentação para me basear, http://tdn.totvs.com/display/public/fluig/Consumo+de+um+WS+SOAP+de+um+Widget
Porém, fica dando o seguinte erro: Uncaught TypeError: Cannot set property 'innerHTML' of undefined
Segue o código abaixo:
var wsUrl = WCMAPI.serverURL + "/webdesk/ECMDatasetService?wsdl";
var that = this;
var wg_cpf = $("#cpf").val();
var wg_pedido = $("#pedido").val();
console.log("CPF: " + wg_cpf + " | Pedido: " + wg_pedido);
// Realiza a chamada Ajax
var soapRequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.dataservice.ecm.technology.totvs.com/"><soapenv:Header/><soapenv:Body><ws:getDataset><companyId>1</companyId><username>admin</username><password>admin</password><name>ds_consulta_rms</name><fields></fields><constraints><item><contraintType>ContraintType.MUST</contraintType><fieldName>CPF_CLIENTE</fieldName><finalValue>1234567890</finalValue><initialValue>1234567890</initialValue><likeSearch>false</likeSearch></item><item><contraintType>ContraintType.MUST</contraintType><fieldName>PED_NUM_PEDIDO_CP</fieldName><finalValue>123456</finalValue><initialValue>123456</initialValue><likeSearch>false</likeSearch></item></constraints><order></order></ws:getDataset></soapenv:Body></soapenv:Envelope>';
//Convertendo para XML, para facilitar a manipulação
var parser = new DOMParser();
var xmlRequest=parser.parseFromString(soapRequest,"text/xml");
// Preenchimento das informações para acessar o Dataset
xmlRequest.getElementsByTagName("companyId")[0].innerHTML = "1";
xmlRequest.getElementsByTagName("username")[0].innerHTML = "admin";
xmlRequest.getElementsByTagName("password")[0].innerHTML = "admin";
xmlRequest.getElementsByTagName("name")[0].innerHTML = "ds_consulta_rms";
// Valores para os campos
xmlRequest.getElementsByName("[constraints='fieldName']")[0].innerHTML = "CPF_CLIENTE";
xmlRequest.getElementsByName("[constraints='finalValue']")[0].innerHTML = wg_cpf;
xmlRequest.getElementsByName("[constraints='initialValue']")[0].innerHTML = wg_cpf;
xmlRequest.getElementsByName("[constraints='fieldName']")[0].innerHTML = "PED_NUM_PEDIDO_CP";
xmlRequest.getElementsByName("[constraints='finalValue']")[0].innerHTML = wg_pedido;
xmlRequest.getElementsByName("[constraints='initialValue']")[0].innerHTML = wg_pedido;
// Acessando o Dataset via WebService
WCMAPI.Create({
url : wsUrl,
contentType : "text/xml",
dataType : "xml",
data : xmlRequest,
success : function(data) {
console.log("Carregou o Pedido da Montagem");
var xmlResp = parser.parseFromString(data.firstChild.innerHTML,"text/xml");
console.log("Documento Publicado: " + xmlResp.getElementsByTagName("documentId")[0].innerHTML);
console.log(xmlResp);
that.preencherDadosDataset(data);
}
});