1 Reply Latest reply on Oct 18, 2011 3:37 PM by eapostol

    Flash Builder 4.5 Data Services Wizard, setting up REST service call returns Internal Error Occurred

    eapostol Level 1

      Dear all -



      I am writing with the confidence that someone will be able to assist me.



      I am using the Flash Builder Data Services Wizard to access a Server that utilizes REST type calls and returns JSON objects. The server is a JETTY server and it apparantly already works and is returning JSON objects (see below for example). It is both HTTP and HTTPS enabled, and right now it has a cross-domain policy file that is wide open (insecure but its not a production server, it's internal).



      The crossdomain file looks like this:



      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">


         <allow-http-request-headers-from domain="*" headers="*" secure="false"   />

         <allow-access-from domain="*" to-ports="*" secure="false"/>

         <site-control permitted-cross-domain-policies="master-only" />




      The crossdomain file is in the jetty server's root directory and is browseable via HTTP and HTTPS (i.e. browsing to it returns the xml)



      Now before all of you say that using wizards sucks (generally) I thought I would utilize the FB Data Services Wizard as at least it would provide a template for which I could build additional code against, or replace and improve the code it produces.


      With that in mind, I browse to the URL of the Jetty Server with any web browser (for example, Google Chrome, Firefox or IE) with a URL like this (the URL is a little confidential at the moment, but the structure is the same)






      *somePort is the SSL port like 8443

      *someKey is a key to access the URL's set of services





      returns a JSON object as a string in the web browser and it appears like the following:






      Looks like the JSON string/object is valid.



      I went through the Flash Builder Data Services Wizard to set up HTTP access to this server. The information that I filled in is described below:



      Do you want to use a Base URL as a prefix for all operation URLs?




      Base URL:




      Name                    : someTask

      Method                    : POST

      Content-Type: application/x-www-form-urlencoded

      URL                              : {someUser}/{somePassword}/someTask



      Service Name: SampleRestapi

      Services Package: services.SampleRestapi

      datatype objects: valueObjects:



      Completing the wizard, I run the Test Operation command. Remember, no authentication is needed to get a JSON string.



      It returns:



      InvocationTargetException: Unable to connect to the URL specified



      I am thinking - okay, but the URL IS browseable (as I originally was able to browse to it, as noted above).





      I continue to test the service by creating a Flex application that accepts a username and password in a form. when the form is submitted, the call to the service is invoked and an event handler returns the result. The code is below (with some minor changes to mask the actual source).



      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"




                                       minWidth="955" minHeight="600">



                                    import mx.controls.Alert;

                                    import mx.rpc.events.ResultEvent;


                                    protected function button_clickHandler(event:MouseEvent):void


                                              isUserValidResult.token = SampleRestAPI.isUserValid(userNameTextInput.text,passwordTextInput.text);




                                    protected function SampleRestAPI_resultHandler(event:ResultEvent):void


                                              // TODO Auto-generated method stub

                                              // print out the results

                                              txtAreaResults.text = event.result.message as String;

                                              // txtAreaResults.appendText( "headers \n" + event.headers.toString() );







                          <SampleRestapi:SampleRestAPI id="SampleRestAPI"

                                                                                                   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"



                          <s:CallResponder id="isUserValidResult"/>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->


                <s:Form defaultButton="{button}">

                          <s:FormItem label="UserName">

                                    <s:TextInput id="userNameTextInput" text="q"/>


                          <s:FormItem label="Password">

                                    <s:TextInput id="passwordTextInput" text="q"/>


                          <s:Button id="button" label="IsUserValid" click="button_clickHandler(event)"/>

                          <s:FormItem  label="results:">

                                    <s:TextArea id="txtAreaResults"/>






      It's a simple application to be sure. When I run it , I get the following returned in the text area field txtAreaResults:



      An Internal Error Occured.



      Which is equivalent to the following JSON string being returned:



      {"success":false,"value":"An Internal Error Occured"}



      It appears that the call is being made, and that a JSON object is being returned... however it does not return the expected results?



      Again the URL constructed is the same:






      So I am wondering what the issue could be:



      1) is it the fact that I am browsing the test application from an insecure (http://) web page containing the Flex application and it is accessing a service through https:// ?



      2) is the JSON string structurally correct? (it appears so).



      3) There is a certificate enabled for HTTPs. it does not match the test site I am using ( the cert is for www.somedomain.com but I am using localhost for testing). Would that be an issue? Google Chrome and IE just asks me to proceed anyway, which I say "yes".



      Any help or assistance on this would be appreciated.







        • 1. Re: Flash Builder 4.5 Data Services Wizard, setting up REST service call returns Internal Error Occurred
          eapostol Level 1

          Hello everyone -


          Since I last posted an interesting update happened. I tested my  Flex application again, it is calling a Jetty Server that returns a JSON object, in different BROWSERS.  I disabled HTTPS for now, and the crossdomain.xml policy file is wide open for testing (ie. allowing every request to return data). So the app accessing the data using HTTP only. Browsers  -  IE, Opera, Firefox and Chrome. Each browser contained the SAME application, revision of the Flash Player ( debugger for firefox, chrome, opera, safari PC; consumer version in IE9,) take a look at the screen shot (safari not shown although the result was the same as IE and chrome)




          Note that Opera and Firefox returned successful values (i.e. successful JSON objects) using the same code generated from the Data Services Wizard. Chrome, IE and, Safari failed with an Internal error. So I am left wondering - WHY? Is it something with the Flash Player? the Browsers?  the Flex SDK? Any thoughts are appreciated. Again, the code is found in the original thread above.