12 Replies Latest reply on Jan 10, 2012 2:16 PM by dhhesslerDataViz

    Cannot Consume Restful Webservice via HTTPS Getting Errors


      I'm trying to consume a Restful web service which use a client's cert to authenticate.  When I attempt to connect, I get the following error from flash:

      faultCode:Server.Error.Request faultString:'HTTP request error' faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"]. URL: https://internalwebsite.mycompany/rest?para1=2.  In addition, network monitor list the following Error java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, pr...


      I have created keystores and truststores as required and added the correct lines to flashbuilder.ini

        • 1. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
          oldMster Level 3

          2032 is a 'general purpose' http request error that isn't very specific.  Is this from an AIR app, or a browser app?  If a browser app, the easiest way to track down http/https errors is to use a browser with developer tools that allow monitoring the network traffic generated / received by the browser (Chrome, firefox with firebug are a couple).  With https, it is about the only useful tool, since it is the only way I know to see the network traffic unencrypted.


          Check the usual things - do you have the cross domain policy file set up on the REST service server, does the cross domain policy file allow https traffic.  From the java error, which must be server side, it appears that isn't the problem, but it would be good to verify it.



          • 2. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
            dhhesslerDataViz Level 1


                   The app is a browser app.  I have A wide open crossdomain file is in place.  I also used fiddler to track through the SSL connection.  No help unfortunately.  I don't think the error is a server side error for two reasons. One, the particular exception is thrown as part of Java attempting to connect to a URI using TSL when an encryption algorithm is "not available" (see Java Api documentation).  This is of course odd since I'm using a standard asymmetric algorithm which I know is supported by Java and my cert is not beyond the bit size supported by Java.  Also, since the client is generating the connection, I'm assuming that under the hood, Flash Player calls the JVM (which version I don't know probably 6, though 7 would be nice considering the benefits to the crypto package of 7).  I could, of course, be wrong.  Two the RESTful service is oddly generated by using .net (so its C# based not java).  If you, or anyone else, has any other suggestions that would be helpful.

            • 3. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
              oldMster Level 3

              Unless you have loaded some 3rd party library into your project that does it, Flash Player/Flex don't require, use, or support Java that I am aware of.


              • 4. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                dhhesslerDataViz Level 1

                All I can tell you that I am definetly not using a 3rd party library.  My code is literally URLLoader(new URLRequest("https://somesite.com/rest/application?params")). Its a real puzzle as to why things are working the way they are...

                • 5. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                  oldMster Level 3

                  Have you tried just typing that url into the browsers address bar?  But then params is probably a bunch of 'stuff', not really just the string "params".


                  I can't help a whole lot more, other than to assure you that there is nothing fundamentally wrong with a restful https call from flex - that is how all of our data connections are made, and we have a lot of data connections!  We aren't using certificate authentication, though, so I suspect that process is where the problem is.


                  • 6. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                    dhhesslerDataViz Level 1

                    That was my conclusion as well.

                    • 7. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                      dhhesslerDataViz Level 1

                      Update: When I connect to the website within a browser and then, in the same browser session, load my swf.  The swf works.  This confirms the conclusion that either something is needed to tell actionscript/flex to connect to an external website with certificate-based authentication or Flash itself can use certificates.

                      • 9. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors



                        I am building a mobile employee directory and for that I am using Flash Builder 4.6/AIR 3.1.0. I am using RESTful web service to get XML results and to display on my mobile application. I am getting the same below error when accessing the webservice from mobile app (Android - Galaxy Tab 7 inch).


                        Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error # 2032"] URL: http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co">http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co ntext-root/jersey/restlabhttp://adfdevp.alshaya.com:7013/RESTEmployeeDetails-http://adfdevp.als haya.com:7013/RESTEmployeeDetails-EmployeeDetails-co ntext-root/jersey/restlabEmployeeDetails-context-root/jersey/restlab


                        The same code is working in Flash Builder 4.6. I have checked Network Monitor to "Disabled" before deploying to mobile. What am i doing wrong here? I am pasting my code below-



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

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

                           xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" xmlns:dao="dao.*"





                            import mx.collections.ArrayCollection;

                            import mx.collections.IList;

                            import mx.collections.XMLListCollection;

                            import mx.events.FlexEvent;

                            import mx.rpc.events.FaultEvent;

                            import mx.rpc.events.ResultEvent;

                            import mx.rpc.xml.SimpleXMLDecoder;

                            import mx.utils.ArrayUtil;


                            import valueObjects.EmployeeDetail;


                            private var myXml:XML;



                            public var resultCollection:IList;

                            public function handleXml(event:ResultEvent):void


                             var xmlListCollection:XMLListCollection = new XMLListCollection(event.result.children());

                             var xmlListCollectionValues:XMLListCollection = new XMLListCollection(event.result.emp.children());

                             var resultArray:Array = xmlListCollection.toArray();

                             var resultArrayValues:Array = xmlListCollectionValues.toArray();



                             var objEmployeeDetails:EmployeeDetail;

                             var resultCollection:ArrayCollection = new ArrayCollection();


                             var j:int = 0;

                             for(var i:int=0;i<resultArray.length;i++){


                              objEmployeeDetails = new EmployeeDetail();

                              objEmployeeDetails.brand = resultArrayValues[j];

                              objEmployeeDetails.division = resultArrayValues[j+1];

                              objEmployeeDetails.email = resultArrayValues[j+2];

                              objEmployeeDetails.employee_name = resultArrayValues[j+3];

                              objEmployeeDetails.employee_number = resultArrayValues[j+4];

                              objEmployeeDetails.grade = resultArrayValues[j+5];

                              objEmployeeDetails.mobile = resultArrayValues[j+6];

                              objEmployeeDetails.position = resultArrayValues[j+7];


                              j = j + 8;




                             list.dataProvider = resultCollection;

                             //return resultCollection;



                            public function handleFault(event:FaultEvent):void


                             //Alert.show(event.fault.faultDetail, "Error");             



                            protected function sesrchEmployee():void









                           <dao:EmployeeDAO id="srv"/>


                           <mx:HTTPService id="xmlRpc"

                               url="http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-co ntext-root/jersey/restlab"



                               resultFormat="e4x" showBusyCursor="true">

                            <mx:request xmlns="">












                           <s:VGroup width="100%">

                           <s:HGroup width="100%">

                            <s:Label top="40" paddingTop="10" paddingRight="13" height="29" text="Employee Name:"/>

                            <s:TextInput id="key" width="559"/>


                           <s:HGroup width="100%">

                            <s:Label height="30" paddingTop="10" text="Employee Number:"/>

                            <s:TextInput id="key1" width="100%"/>







                           <s:Button icon="@Embed('assets/search.png')" click="sesrchEmployee()"/> 



                        <s:List id="list" top="0" bottom="0" left="0" right="0" 

                            change="navigator.pushView(EmployeeDetails, list.selectedItem)">



                             <s:IconItemRenderer label="{data.employee_name}"









                        Please help me to resolve this issue as soon as possible. Appreciate your quick response in this regard.




                        Murtaza Ghodawala

                        Mobile: +965 97180549


                        • 10. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                          dhhesslerDataViz Level 1

                          I'm going to try and give you as complete as answer as I can.  Error#2032 is a generic IO error.  Adobe did not do a great job here, so it could be a lot of things.


                          First of all, check your url.  I notice you have a space in the word context.  So the url currently is co ntext.  It could very well simply be that url isn't right.  This is an easy check.  Copy the url and paste it into any web browser.


                          If this doesn't work, which frankly I hope it is, my experence says it could be a number of security related errors.  I'm going to assume that RESTful server requires some sort of authentication.  If it doesn't, you should stop what your doing and get that to work, or get the owner of the service to do so.  Exposing your data to the general public is a very very bad idea.  Especially, if you data contain any sort of personal information or business secrets.  The industry standard here is PKI based authentication.  There a lot of white papers out there on why that is and why it is better than having a username:password based authentication so I'm going to go into any detail on that.  Just make sure you get it done if you can.


                          Having said that... Your problem is most likely a crossdomain file.  Adobe has great documentation on how to setup a crossdomain file and its contents.  This file should be found on your server (in your case at http://adfdevp.alshaya.com:7013/crossdomain.xml).  In most cases that seems to fix the issue.


                          If that doesn't work, what you have a security nightmare on your hands.  For whatever reason, Air is not loading username:pass or pki and/or not setting up the correct TLS security.  You can use the network monitor to detect this.  If you in the place, my recommendation is look into a different technology other than Flex/as3.  Adobe's pulling the plug on it and moving to HTML5 for mobile devices or you can use java (though you don't get the prettiness of Flex/as3).  After about a months worth of solid research, I found that Adahl's Law starts to apply and its better to take this as an opportunity to research your company's response to the post-flash player/Air conumdrum.  It's a better use of your time.

                          • 11. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                            Murtaza_Ghodawala Level 1



                            Thanks for your detailed reply. Two things I want to clarify -


                            1. The actual URL is

                            http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-context-root/jersey/restlab. My bad somehow I pasted the URL wrongly on the post.


                            URL is working fine and giving results as expected, I have checked it on the mobile browser as well.


                            2. I am using Basic Authentication for my RESTful Webservice. So if the authentication cookie is not avaialable in the browser, then HTTP should throw a basic username/password popup and after giving valid input, webservice should return the appropriate results.


                            Please let me know what needs to be done there? Thanks and Appreciate your response.



                            Murtaza Ghodawala

                            Mobile: +965 97180549


                            • 12. Re: Cannot Consume Restful Webservice via HTTPS Getting Errors
                              dhhesslerDataViz Level 1

                              If your using Flash Builder, there is a built in wizard to set this up.  It will even create the entity classes for you.   If not, you should look into URLRequest and URLLoader actionscript classes.  It's not terribly complicated and you can just cast the URLLoader data as XML.  As3 is really easy with using XML.  Here's the jist (assume root is an XML object):

                              root.foo gives you root a iterable list of XML objects where foo is the name of the child

                              root.@foo is the value of root's attribute called foo.