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

New Contributor
Posts: 7
Registered: ‎04-19-2010
My Device: 9700
My Carrier: Vodafone
Accepted Solution

Calling WCF service from Javascript



I have a very simple WCF based WebService - "HelloWorld()" which return "Hello World". Using javascript and xmlHttpRequest I can invoke this service from Browser. But the same page dosn't work when run from Blackberry.


Issue: xmlHttp.readyState alerts "1" twice, but don't proceed further.





function HelloWorld()
// Create HTTP request
var xmlHttp;
xmlHttp = new XMLHttpRequest();

// Create result handler
if(xmlHttp.readyState == 4){

var url = "http://localhost:2398/HelloWorldService/Service.svc"
var body = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body>' +
'<HelloWorld xmlns="urn:HelloWorld" />' +
// Send the HTTP request
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "text/xml; charset=utf-8");
xmlHttp.setRequestHeader("SOAPAction", "urn:HelloWorld/IHelloWorld/HelloWorld");

 I see an alert message "1" (in bold line above), then again "1" and then no message comes. Blackberry's small loading icon rotates few times and it too vanishes.


The same script works well from IE.



Any Suggestions?



Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Calling WCF service from Javascript

The following thread may be able to help you out:



Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 7
Registered: ‎04-19-2010
My Device: 9700
My Carrier: Vodafone

Re: Calling WCF service from Javascript



Thanks for the link but that didn't help me as I was doing the same. While trying options, I added all blackberry features to the web service domain I added earlier. After this, service started working fine. I am not sure, which specific blackberry api feature of long list made it work, but adding all resolved this problem.