Please, I'm stuck in a little problem using getElementsByTagName command on a js file with a PhoneGap project. I'm consuming a asp.net web service that works perfectly, but I failed to get the result that the web service is returning me, and that is string
from <IngresarRegistroMovilResult>
tag.
This is my function that receives the web service return:
function processResult() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var theXML = xmlhttp.responseXML.documentElement;
var resultadoWebService = theXML.getElementsByTagName('string')[0].firstChild.nodeValue;
var output = "Resultado: ";
output += resultadoWebService;
console.log("Pasamos por processResult, con var output:"+output);
document.getElementById("resultadows").innerHTML = output;
}
};
This is the specification of the web service:
POST /servicio.asmx HTTP/1.1
Host: dondeestamifamilia.masterdevelopment.co
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<IngresarRegistroMovil xmlns="http://dondeestamifamilia.masterdevelopment.co/">
<hashString>string</hashString>
</IngresarRegistroMovil>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<IngresarRegistroMovilResponse xmlns="http://dondeestamifamilia.masterdevelopment.co/">
<IngresarRegistroMovilResult>string</IngresarRegistroMovilResult>
</IngresarRegistroMovilResponse>
</soap12:Body>
</soap12:Envelope>
This is the fragment corresponding to IngresarRegistroMovil method, from the wsdl:
<s:element name="IngresarRegistroMovil">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="hashString" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="IngresarRegistroMovilResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="IngresarRegistroMovilResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
I've tried theXML.getElementsByTagName('string')[0].firstChild.nodeValue;
but I get: Uncaught TypeError: Cannot read property 'firstChild' of undefined
. theXML.getElementsByTagName('string')[0];
but I get: undefined
. theXML.getElementsByTagName('string')[0].nodeValue;
but I get: Uncaught TypeError: Cannot read property 'nodeValue' of undefined
.
Please, your great support will be extremely valuable to me.
Thanks.
The tagname is IngresarRegistroMovilResult
not string
which you can acces by theXML.getElementsByTagName('IngresarRegistroMovilResult')[0].textContent
(if I made no typo)