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
Contributor
Posts: 26
Registered: ‎07-24-2009
My Device: Not Specified

Getting around COR in Webworks

Hi there,

 

Having a small nightmare trying to work out the best way to send SOAP data using jQuery. The code I'm using builds the request and then uses jQuery's ajax function to POST the data.

 

 

jQuery.ajax({
url: url,
type: "POST",
async: true,
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", soapAction);
},
data: xml

For testing (using the Ripple Emulator) I'm posting from localhost, to a local IP (10.0.7.1 in case you need to know). However it isn't working because of Access-Control-Allow-Origin. 

Here are the sent headers

OPTIONS /MediaRenderer/RenderingControl/Control HTTP/1.1 Host: 10.0.7.1:1400 Connection: keep-alive Access-Control-Request-Method: POST Origin: http://localhost User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 Access-Control-Request-Headers: origin, soapaction, content-type, accept Accept: */* Referer: http://localhost/webapp/ Accept-Encoding: gzip,deflate,sdch Accept-Language: en-GB,en-US;q=0.8,en;q=0.6 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

And the response headers:

HTTP/1.1 500 Internal Server Error
CONTENT-LENGTH: 347
CONTENT-TYPE: text/xml; charset="utf-8"
EXT: 
SERVER: Linux UPnP/1.0 Sonos/19.3-53220b (ZP120)
Connection: close

Normally this would be easy, as I'd just use a PHP proxy however obviously in Webworks this isn't possible. So the question is - is it possible to use an extension or custom API as a proxy to do such request, or is Webworks setup so as to allow CORS? Any help would be greatly appreciated!

Contributor
Posts: 26
Registered: ‎07-24-2009
My Device: Not Specified

Re: Getting around COR in Webworks

How funny, just read the topic about 3 down which suggests adding this to Chrome:
 --disable-web-security
However, when the application is packaged and installed, will it actually work on the Playbook? Basically can't seem to find out if like Internet Explorer the Playbook supports data access from different domains.
Highlighted
BlackBerry Development Advisor
Posts: 762
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Getting around COR in Webworks

[ Edited ]

You'll need to make sure the target domain is whitelisted in your config.xml

 

Docs: https://developer.blackberry.com/html5/documentation/code_sample_creating_a_bb_widget_config_documen...

 

<access uri="http://www.somedomain.com" subdomains="true">
  </access>