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
New Contributor
Posts: 6
Registered: ‎06-30-2011
My Device: 9800 Torch
Accepted Solution

Not able to connect to a remote Wcf service

I am trying to connect to a wcf service hosted on a server using this code

 

function Getresults() {         

    var xmlhttp;
            if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {             

 try {                   

xmlhttp = new XMLHttpRequest();                }               

catch (e) {                   

xmlhttp = false;           

  }           

}
            return xmlhttp;       

}

 

function getDynamicData() {           

var url = "http://xx.x.10.246/Service.Wcf/ReportsService.svc/Volume";           

xmlHttp.open("GET", url, true);           

xmlHttp.onreadystatechange = callbackFunction;           

xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");           

xmlHttp.send(null);                 

 }

 

function callbackFunction() {           

alert(xmlHttp.readyState);                       

if (xmlHttp.readyState != 4)               

return;           

alert(xmlHttp.status);

alert(xmlHttp.statusText);           

alert(xmlHttp.responseText);            

 }

 

I always get the alert message as 400 Bad request but the expected response is xml. I added it in the domain. I am able to call the service but not the function inside the service and the function exists.  Could anyone help me with this?

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

Re: Not able to connect to a remote Wcf service

Have you whitelisted the domain of the server that you are trying to reach using the <access> element in your config.xml file?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 6
Registered: ‎06-30-2011
My Device: 9800 Torch

Re: Not able to connect to a remote Wcf service

Yes I listed it in the domain. I figured out the problem I was sending the soap request incorrect. But thank you for the solution.