4 Replies Latest reply on Jan 13, 2012 9:35 PM by archemedia

    httpServices not working Online but working with Flash Builder

    Asim Kh Level 1

      I am using Flash Builder and worked on different modules. it works perfectly when am testing with Flash Builder

      but once i close it, the httpservices stop working. I search and now got error message i.e.



      Can't load data: (mx.messaging.messages::ErrorMessage)#0
        body = ""
        clientId = "DirectHTTPChannel0"
        correlationId = "A10EF203-C28B-A5C6-73D6-1C765EAA0714"
        destination = ""
        extendedData = (null)
        faultCode = "Server.Error.Request"
        faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/1/users/show.xml?screen_name=charagh?hostport=api.twitter.com&https=N&id=A10EF203-C28B-A5C6-73D6-1C765EAA0714"]. URL: http://api.twitter.com/1/users/show.xml?screen_name=charagh"
        faultString = "HTTP request error"
        headers = (Object)#1
          DSStatusCode = 0
        messageId = "542DB993-AA3F-7E05-636C-1C7662BB7FFF"
        rootCause = (flash.events::IOErrorEvent)#2
          bubbles = false
          cancelable = false
          currentTarget = (flash.net::URLLoader)#3
            bytesLoaded = 0
            bytesTotal = 0
            data = ""
            dataFormat = "text"
          errorID = 0
          eventPhase = 2
          target = (flash.net::URLLoader)#3
          text = "Error #2032: Stream Error. URL: http://localhost:37813/1/users/show.xml?screen_name=charagh?hostport=api.twitter.com&https=N&id=A10EF203-C28B-A5C6-73D6-1C765EAA0714"
          type = "ioError"
        timestamp = 0
        timeToLive = 0



      my code i.e.



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
                             width="550" height="58" backgroundAlpha="1.0" backgroundColor="#000000"
                             borderVisible="false" creationComplete="init(event)" layout="absolute">
                                    import mx.events.FlexEvent;
                                    import mx.rpc.events.FaultEvent;
                                    import mx.rpc.events.ResultEvent;
                                    import mx.controls.Alert;
                                    import mx.rpc.http.HTTPService;
                                    private var twitterText:String;
                                    private var twitterCount:String;
                                    private var tweetdate:String;
                                    private var twitterImage:String;
                                    protected function image1_clickHandler(event:MouseEvent):void
                                              navigateToURL(new URLRequest("https://twitter.com/charagh"),"_blank");
                                    protected function init(event:FlexEvent):void
                                              twitterText = "charagh";
                                    protected function tweetUser_resultHandler(event:ResultEvent):void
                                              tweetdate = event.result.user.status.created_at;
                                              twitterCount = event.result.user.status.text +"  "+tweetdate;
                                              twitterImage = event.result.user.profile_image_url;
                                    protected function tweetUser_faultHandler(event:FaultEvent):void
                                              Alert.show("Can't load data: " + event.message);
                          <s:HTTPService id="tweetUser" method="GET" result="tweetUser_resultHandler(event)" fault="tweetUser_faultHandler(event)">
                <s:Image  buttonMode="true" width="48" height="48" x="5" y="5" click="image1_clickHandler(event)" source="{twitterImage}"/>
                <s:Label id="twitterNumber" x="56" y="5" width="488" height="47" color="#EDEDED"
                                     fontFamily="Georgia" fontSize="12" fontWeight="normal" text="{twitterCount}"
                                     textAlign="center" verticalAlign="middle"/>
        • 1. Re: httpServices not working Online but working with Flash Builder
          Murtaza_Ghodawala Level 1



          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


          • 2. Re: httpServices not working Online but working with Flash Builder
            archemedia Level 4

            The link in your code:

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


            doesn't return anything! Make sure the link returns valid xml.


            Also, did you put a crossdomain.xml policy file on your server?



            • 3. Re: httpServices not working Online but working with Flash Builder
              Murtaza_Ghodawala Level 1

              Hi Dany,


              The url is correct (http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-context-root/jersey/restlab) and returning valid XML results. By mistake I put a space in the word "context", but never mind the url is correct and I have validated it in the mobile browser as well.


              Regarding crossdomain.xml file, do we need to put it for our mobile app as well? I am directly deploying my app to Android mobile and there was no documentation regarding this file which you are stating. Can you please let me know how, where and what to put it in that file. Appreciate your kind help. Thanks.





              Murtaza Ghodawala

              Mobile: +965 97180549


              • 4. Re: httpServices not working Online but working with Flash Builder
                archemedia Level 4

                I don't know if it's necessary but it can't harm. You are accessing a remote domain from within air, so placing an crossdomain file can't harm.

                Put it in the directory where your xml is located or generated or a directory above that. Name the file crossdomain.xml and add at least this


                <?xml version="1.0"?>

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


                   <allow-access-from domain="*" />




                If you're deploying to Android, make sure you check your -app.xml. You have to set Android permissions. At the bottom of this file you'll find

                <!-- Specify Android specific tags that get passed to AndroidManifest.xml file. -->

                Uncomment the manifestAdditions.


                Hope this helps,