0

I am callng a servlet from a browser based Flex app but get the following exception:

Error #2044: Unhandled securityError:. text=Error #2170: Security sandbox violation: http://MyURL/web-player/WebPlayer.swf cannot send HTTP headers to http:/MyOtherUrl:1936/ImageUpload.
      at WebPlayer/screenGrab()
      at WebPlayer/__exportImageButton_click()

I have the following crossdomain.xml being served from

http://MyOtherUrl/ 

and

http://MyOtherUrl:1936/ 

(the port the servlet is served from).

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
  <cross-domain-policy>
  <allow-access-from domain="*" />
  <allow-http-request-headers-from domain='*' headers="*" secure="false"/>
  <site-control permitted-cross-domain-policies="all"/>
</cross-domain-policy>

What am I doing wrong?


Edit to include code


var urlRequest:URLRequest = new URLRequest();
urlRequest.url = "http://MyUrl:1936/ImageUpload";
urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
urlRequest.method = URLRequestMethod.POST;
var params:Object = new Object();
params.userId = userId;
params.videoId = videoId;
urlRequest.data = UploadPostHelper.getPostData("splash.jpg", jpegStream, params);
urlRequest.requestHeaders.push( new URLRequestHeader( 'multipart/form-data', 'image/jpg' ) );

var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(urlRequest);
codeghost
  • 1,014
  • 7
  • 14
  • How do you "Call a Servlet" in a Flex app? I'm not familiar with that terminology; so I'm unclear exactly what you're trying to accomplish. – JeffryHouser May 17 '12 at 15:49
  • I'm building a UrlRequest passing the various data items I require and adding the header then call load on the request. I know that the servlet call works as I can both call both a local version and the deployed version, but only when I'm running my Flex app in the sandbox. – codeghost May 17 '12 at 15:51
  • I've edited the question to include the pertinent code, as I say though I can execute this code successfully when running in the security sandbox. – codeghost May 18 '12 at 10:57

1 Answers1

0

try checking whether your crossdomain.xml is accessible from browser. Go to MyOtherUrl:1936/crossdomain.xml

Check the traffic with http://www.charlesproxy.com/ to see what is the error.

prashanth
  • 445
  • 5
  • 14
  • This is not an answer; but merely troubleshooting suggestions. It is usually considered best practice to add these as a comment on the main question; not as a formal answer. – JeffryHouser May 17 '12 at 22:09
  • Yes the crossdomain.xml is accessible from a browser. – codeghost May 18 '12 at 10:59