5 Replies Latest reply on Mar 16, 2012 4:56 AM by C.Sathish

    httpServices not working Online but working with Flash Builder

    Asim Kh

      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"

                             xmlns:s="library://ns.adobe.com/flex/spark"

                             xmlns:mx="library://ns.adobe.com/flex/mx"

                             width="550" height="58" backgroundAlpha="1.0"

      backgroundColor="#000000"

                             borderVisible="false" creationComplete="init(event)"

      layout="absolute">

       

                <fx:Script>

                          <![CDATA[

                                    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";

                                              tweetUser.url="

      http://api.twitter.com/1/users/show.xml?screen_name="+twitterText;

                                              tweetUser.send();

       

                                    }

       

                                    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);

       

                                    }

       

                          ]]>

                </fx:Script>

       

                <fx:Declarations>

                          <s:HTTPService id="tweetUser" method="GET"

      result="tweetUser_resultHandler(event)"

      fault="tweetUser_faultHandler(event)">

       

                          </s:HTTPService>

                </fx:Declarations>

                <s:Image  buttonMode="true" width="48" height="48" x="5" y="5"

      click="image1_clickHandler(event)" source=""/>

       

                <s:Label id="twitterNumber" x="56" y="5" width="488" height="47"

      color="#EDEDED"

                                     fontFamily="Georgia" fontSize="12"

      fontWeight="normal" text=""

                                     textAlign="center" verticalAlign="middle"/>

      </mx:Module>

      ===================

       

      Regards,

      Asim Ahmed

       

      ~ http://www.charag.com ~

       

        • 1. Re: httpServices not working Online but working with Flash Builder
          Asim Kh Level 1

          updated code: with cross domain policy! but still getting error

           

           

           

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

          <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"

                                 xmlns:s="library://ns.adobe.com/flex/spark"

                                 xmlns:mx="library://ns.adobe.com/flex/mx"

                                 width="550" height="58" backgroundAlpha="1.0" backgroundColor="#000000"

                                 borderVisible="false" creationComplete="init(event)" layout="absolute">

                    <fx:Style>

                              @namespace s "library://ns.adobe.com/flex/spark";

                              @namespace mx "library://ns.adobe.com/flex/mx";

           

           

           

                              @font-face{

                                        src: url("./module/font/fonts/DroidSans.ttf");

                                        fontFamily: "Base02";

                              }

           

           

           

                              mx|Alert {

                                        titleStyleName: "alertTitle";

                                        messageStyleName: "alertMessage";

                                        buttonStyleName: "alertButton";

                                        cornerRadius: 0;

                                        embedFonts: true;

                                        fontFamily: Base02;

                                        backgroundColor:aqua;

                              }

           

                              .alertButton {

                                        letterSpacing: 0;

                                        fontSize: 11;

                                        cornerRadius: 10;

                                        fontWeight: normal;

                                        textRollOverColor: white;

                                        color: red;

                                        skin: ClassReference(null);

                              }

           

                              .alertTitle {

                                        letterSpacing: 0;

                                        fontSize: 14;

                                        color: red;

                              }

           

                              .alertMessage {

                                        letterSpacing: 0;

                                        fontSize: 10;

                                        fontWeight: normal;

                                        color: black;

                              }

           

                    </fx:Style>

                    <fx:Script>

                              <![CDATA[

                                        import module.user_logged;

           

                                        import mx.collections.ArrayCollection;

                                        import mx.collections.XMLListCollection;

                                        import mx.controls.Alert;

                                        import mx.events.FlexEvent;

                                        import mx.rpc.events.FaultEvent;

                                        import mx.rpc.events.ResultEvent;

                                        import mx.rpc.http.HTTPService;

           

                                        private var twitterText:String;

           

                                        [Bindable]

                                        private var twitterCount:String;

           

                                        [Bindable]

                                        private var tweetdate:String;

           

                                        [Bindable]

                                        private var twitterImage:String;

           

           

                                        [Bindable]

                                        private var tweetArray:ArrayCollection;

           

                                        [Bindable]

                                        private var datalist:XMLListCollection;

           

                                        private var a:Alert;

           

                                        protected function image1_clickHandler(event:MouseEvent):void

                                        {

                                                  navigateToURL(new URLRequest("https://twitter.com/charagh"),"_blank");

           

                                        }

           

                                        protected function init(event:FlexEvent):void

                                        {

                                                  Security.allowDomain( "charag.com" );

                                                  Security.loadPolicyFile( "./module/crossdomain.xml" );

           

                                                  var request:URLRequest =

                                                  new URLRequest( "./module/crossdomain.xml" );

                                                  var loader:URLLoader = new URLLoader();

                                                  loader.load(request);

           

           

                                                  twitterText = "charagh";

                                                  tweetUser.url="http://api.twitter.com/1/users/show.xml?screen_name="+twitterText;

                                                  tweetUser.send();

                                                  tweetUser.addEventListener(ResultEvent.RESULT,tweetUser_resultHandler );

           

                                        }

           

                                        protected function tweetUser_resultHandler(event:ResultEvent):void

                                        {

           

                                                  Alert.buttonWidth = 120;

                                                  var x:XML = event.result as XML;

                                                  var childName:String = "status";

                                                  //Alert.show(x.child(childName).text);

                                                  yourmessage = x.profile_image_url;

           

                                                  a = Alert.show( yourmessage,title);

                                                  a.mx_internal::alertForm.mx_internal::textField.selectable = false;

           

           

                                                  twitterImage = x.profile_image_url;

                                                  twitterText = x.status.text;

                                                  tweetdate = x.status.created_at;

                                                  twitterCount = twitterText+"  "+tweetdate;

           

                                        }

           

                                        protected function tweetUser_faultHandler(event:FaultEvent):void

                                        {

                                                  var faultstring:String = event.fault.faultString;

                                                  a = Alert.show(faultstring);

           

           

                                        }

           

                              ]]>

                    </fx:Script>

           

                    <fx:Declarations>

                              <fx:String id="title">Error Message</fx:String>

                              <fx:String id="yourmessage"></fx:String>

                              <s:HTTPService id="tweetUser" useProxy="false" method="GET" fault="tweetUser_faultHandler(event)" resultFormat="e4x">

                                                  </s:HTTPService>

                    </fx:Declarations>

                    <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"/>

          </mx:Module>

          • 2. Re: httpServices not working Online but working with Flash Builder
            Asim Kh Level 1

            i placed crossdomain.xml

             

            i.e.

            <?xml version="1.0"?>

            <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">

            <cross-domain-policy xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">

             

            <allow-access-from domain="charag.com"/>

            <allow-access-from domain="*.charag.com"/>

             

            <allow-access-from domain="a1.twimg.com"/>

             

            <allow-access-from domain="*.twitter.com"/>

            <allow-access-from domain="twitter.com"/>

            <allow-access-from domain="api.twitter.com"/>

            <allow-access-from domain="search.twitter.com"/>

            <allow-access-from domain="static.twitter.com"/>

             

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

            <allow-access-from domain="a1.twimg.com"/>

             

            <allow-http-request-headers-from domain="*.twitter.com" headers="*" secure="true"/>

             

            </cross-domain-policy>

             

             

             

            but the problem is, the file works fine once i test in flash builder but once i close it, it stops working and generates error but in debug mode it does show error during flash builder testing!

             

            any suggestions to solve the error!?

             

            ============

            local error i.e. http://localhost/fb/cg7/

            ============

             

            Fault 0 (Error):

            [Server.Error.Request]

             

            FAULT MESSAGE: faultCode:Server.Error.Request faultString:'HTTP request error' 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=7DC25F2C-E9EC-2E95-1389-34C9A2061624"]. URL:http://api.twitter.com/1/users/show.xml?screen_name=charagh'

             

            FAULT DETAILS: 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=7DC25F2C-E9EC-2E95-1389-34C9A2061624"]. URL: http://api.twitter.com/1/users/show.xml?screen_name=charagh

             

            FAULT STRING: HTTP request error

             

             

             

             

            ============

            online error i.e. http://charag.com/fb/cg7/

            ============

             

            Fault 0 (Error):

            [Channel.Security.Error]

             

            FAULT MESSAGE: faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'

             

            FAULT DETAILS: Destination: DefaultHTTP

             

            FAULT STRING: Security error accessing url

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

              Hi,

               

              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.*"

                 xmlns:mx="library://ns.adobe.com/flex/mx">

               

              <fx:Script>

                 <![CDATA[

                  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;

                  [Bindable]

                  private var myXml:XML;

                 

                  [Bindable]

                  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;

                    resultCollection.addItem(objEmployeeDetails);

                   

                   }

                   list.dataProvider = resultCollection;

                   //return resultCollection;

                  }

                 

                  public function handleFault(event:FaultEvent):void

                  {

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

                  }

                 

                  protected function sesrchEmployee():void

                  {

                   xmlRpc.send();

                  }

                 

                 ]]>

              </fx:Script>

               

              <fx:Declarations>

                 <dao:EmployeeDAO id="srv"/>

                

                 <mx:HTTPService id="xmlRpc"

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

                     result="handleXml(event)"

                     fault="handleFault(event)"

                     resultFormat="e4x" showBusyCursor="true">

                  <mx:request xmlns="">

                   <data>{key.text}</data>

                   <data>{key1.text}</data>

                  </mx:request>

                 </mx:HTTPService>

                

                

              </fx:Declarations>

               

              <s:navigationContent/>

               

              <s:titleContent>

                 <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>

                 <s:HGroup width="100%">

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

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

                 </s:HGroup>

                

                 </s:VGroup>

              </s:titleContent>

               

              <s:actionContent>

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

              </s:actionContent>

               

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

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

                 <s:itemRenderer>

                  <fx:Component>

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

                        messageField="position">

                   </s:IconItemRenderer>

                  </fx:Component>

                 </s:itemRenderer>

              </s:List>

               

              </s:View>

               

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

               

              Thanks,

               

              Murtaza Ghodawala

              Mobile: +965 97180549

              murtaza_ghoda82@hotmail.com

              • 4. Re: httpServices not working Online but working with Flash Builder
                C.Sathish

                Hi Asim Kh,

                 

                i am also getting the same error. Have you fixed this issue? if so, please do let me know.

                • 5. Re: httpServices not working Online but working with Flash Builder
                  C.Sathish Level 1

                  Changing the Compiler Arguments -use-network=false worked for me,