Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Consume a xml web service and parse it

As i said test with device not with desktop browser 

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Consume a xml web service and parse it


kamal_nigam wrote:

As i said test with device not with desktop browser 


@FansVannel: Like kamal_nigam wrote, test with the device directly. Using XHR on a local hosted side in your browser you will end up in a CORS problem in every case when accessing remote services. Have a closer look here: https://developer.mozilla.org/en/http_access_control


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
New Developer
Posts: 36
Registered: ‎12-28-2010
My Device: Red Z10, DevAlpha C, Bold 9900, PlayBook
My Carrier: Sprint, AT&T

Re: Consume a xml web service and parse it

Yeah, you need to do the ajax call from a real device.

Onward to BBJam Asia 2013!
twitter/github: @georgemck http://www.bbdevla.com
Developer
Posts: 166
Registered: ‎03-04-2011
My Device: Playbook

Re: Consume a xml web service and parse it


LBP wrote:

kamal_nigam wrote:

As i said test with device not with desktop browser 


@FansVannel: Like kamal_nigam wrote, test with the device directly. Using XHR on a local hosted side in your browser you will end up in a CORS problem in every case when accessing remote services. Have a closer look here: https://developer.mozilla.org/en/http_access_control


I've tested that code on Ripple emulator on Mac (because on Windows Ripple doesn't work) and that code works. I have also tested it with Ripple Chrome extension on Windows 7 Ultimate 64 bits and it doesn't work.

 

The next step will be test it on a real device.

 

By the way, If I want to use it on Playbook, do you know if that AJAX Webservice call will work?

Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Consume a xml web service and parse it

yes it should.

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Consume a xml web service and parse it


VansFannel wrote:

LBP wrote:

kamal_nigam wrote:

As i said test with device not with desktop browser 


@FansVannel: Like kamal_nigam wrote, test with the device directly. Using XHR on a local hosted side in your browser you will end up in a CORS problem in every case when accessing remote services. Have a closer look here: https://developer.mozilla.org/en/http_access_control


I've tested that code on Ripple emulator on Mac (because on Windows Ripple doesn't work) and that code works. I have also tested it with Ripple Chrome extension on Windows 7 Ultimate 64 bits and it doesn't work.

 

The next step will be test it on a real device.

 

By the way, If I want to use it on Playbook, do you know if that AJAX Webservice call will work?


The problem is CORS when using XHR/Ajax via Browser from a local to a cross domain remote URL as I wrote before. We also tried to work with such things month ago for a customer and in browser it didn't work, but then we pushed it to the device and it was working. Since an app is something special you need to access all the sources, also if not same origin, so you shouldn't have an issue with it.

 

And yes, PlayBook works well doing XHR/Ajax calls, we are doing same things on PlayBook.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Trusted Contributor
Posts: 166
Registered: ‎12-09-2011
My Device: 9550,9300,9800,9700,9900,9850,9860

Re: Consume a xml web service and parse it

Hi VansFannel,

Use Javascript Parsing, it is very easy and standard to use.
The tutorial is available in this given link:
http://www.w3schools.com/dom/dom_parser.asp 

Thanks & Regards,
Nitish Subudhi

Feel Free To Press The Like Button On The Right Side To Thank The User That Helped You.
Please Mark Posts As Solved If You Found a Solution.
Highlighted
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: Consume a xml web service and parse it

Try this call sendRequest("https://.......")

 

in the getResponse() you will get response. 

 

 

function CreateXmlHttpReq(handler) {
var xmlhttp = null;

if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
// users with activeX off
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
}

var xmlhttp2 = xmlhttp;
if (xmlhttp2)
xmlhttp2.onreadystatechange = handler;

return xmlhttp2;
}

function XmlHttpGET(xmlhttp, url) {
try {
xmlhttp.open("GET", url, true);

xmlhttp.send();
} catch (e) {
}
}

function sendRequest(var _url) {
isExitPopup = true;
var url = _url;
myxmlhttp = CreateXmlHttpReq(getResponse);

if (myxmlhttp) {
XmlHttpGET(myxmlhttp, url);
} else {
alert("An error occured while attempting to process your request.");
}
}

function getResponse() {
if (myxmlhttp.readyState == 4) {
// success
if (myxmlhttp.status == 200) {
xmlDoc = myxmlhttp.responseXML;
document.getElementById("desc").innerHTML= xmlDoc.getElementsByTagName('description')[0].firstChild.nodeValue;

} else {
alert("There was a problem retrieving the data:\n" + req.statusText);
}
}
}

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------