0 Replies Latest reply on Sep 14, 2009 8:30 AM by indramaryati

    Error:Security error accessing url, run SWF from bin-release

    indramaryati

      Hi all flex expert!!

       

      I have error when accessing Web Service from Flex Builder. First, I run SWF file from bin-debug AND it works fine. So i export to release build and place it to folder "bin-release". I run SWF from bin-release AND it's NOT work. What is the differences between bin-debug and bin-release???

       

      Here's the error when i accessing WSDL from Amazon (i know amazon has new parameter for accessing it WSDL, so i used free.apisigning.com and can work normally):

      [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://free.apisigning.com/AWSECommerceService/AWSECommerceService.wsdl)"]
          at mx.rpc.wsdl::WSDLLoader/faultHandler()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
          at mx.rpc::Responder/fault()
          at mx.rpc::AsyncRequest/fault()
          at DirectHTTPMessageResponder/securityErrorHandler()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/redirectEvent()

       

      And here's the code for my Flex Application (search.mxml):

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#738a9a"
          horizontalScrollPolicy="auto" width="895" height="688">
        <mx:Script>
        <![CDATA[
            import com.adobe.viewsource.ViewSource;
          import mx.rpc.events.FaultEvent;
          import mx.formatters.DateFormatter;
          import mx.collections.ArrayCollection;
          import mx.rpc.events.ResultEvent;
          import mx.controls.Alert;
         
          [Bindable]
          private var itemResults:ArrayCollection;
         
          [Bindable]
          private var currentItem:Object;
         
          [Bindable]
          private var currentItemDetails:XML;
         
          [Bindable]
          private var keywords:String = "";
         
          private function sendRequest():void
          {
            var srcUrl:String = Application.application.parameters.srcUrl;
            if(srcUrl)
              ViewSource.addMenuItem(this, srcUrl);
             
            keywords = escape(keywords);
            AmazonSearch.ItemSearch.send();
          }
         
          private var firstSearch:Boolean = true;
         
          private function showItemSearchResult(res:ResultEvent):void
          {
            if(res.result) {
              itemResults = res.result.Items.Item as ArrayCollection;
              if(firstSearch) {
                dgItems.selectedIndex = 0;
                getAmazonItemInfo();
                firstSearch = false;
              }
            }
          }
         
          private function getItemArtist(item:Object,
            column:DataGridColumn):String
          {
            return item.ItemAttributes.Artist;
          }
         
          private function getItemTitle(item:Object,
            column:DataGridColumn):String
          {
            return item.ItemAttributes.Title;
          }
         
          private function getItemLabel(item:Object,
            column:DataGridColumn):String
          {
            return item.ItemAttributes.Manufacturer;
          }
        
          private function showItemLookupResults(res:ResultEvent):void
          {
            currentItemDetails = res.result[0].*::Items[0].*::Item[0];
            var titleString:String = "";
            if(!currentItemDetails.ItemAttributes.Artist)
              titleString = "Unknown - " + currentItemDetails.ItemAttributes.Title;
            else
              titleString = currentItemDetails.*::ItemAttributes.*::Artist + " - " + currentItemDetails.*::ItemAttributes.*::Title;
            lblArtistTitle.text = titleString;
           
            var reviewString:String = "";
            if(currentItemDetails.*::EditorialReviews.*::EditorialReview is XMLList)
            {
              for each (var review:Object in currentItemDetails.*::EditorialReviews.*::EditorialReview)
              {
                reviewString += (review.*::Content + "<br /><br />");
              }
            } else {
              if(!currentItemDetails.*::EditorialReviews)
                reviewString = "No Reviews Available"
              else
                reviewString = currentItemDetails.*::EditorialReviews.*::EditorialReview.*::Content;
            }
            txtReview.htmlText = reviewString;
           
            var imgUrl:String = "";
            if(currentItemDetails.*::LargeImage)
              imgUrl = currentItemDetails.*::LargeImage.*::URL;
            else if (currentItemDetails.*::MediumImage)
              imgUrl = currentItemDetails.*::MediumImage.*::URL;
            else if (currentItemDetails.*::SmallImage)
              imgUrl = currentItemDetails.*::SmallImage.*::URL;
             
            imgAlbumCover.source = imgUrl;
          }

       

          private function faultShow(event:FaultEvent):void
          {
            var er:String = event.type;
            //Alert.show(event.message.toString());
          }
         
          private function getAmazonItemInfo():void
          {
            AmazonSearch.ItemLookup.send()
          }
        ]]>
        </mx:Script>
       
        <mx:WebService id="AmazonSearch"
          wsdl="http://free.apisigning.com/AWSECommerceService/AWSECommerceService.wsdl"
          showBusyCursor="true" >
          <mx:operation name="ItemSearch" resultFormat="object" result="showItemSearchResult(event)">
            <mx:request>
              <AWSAccessKeyId>AKIAJTFVY5F2JFCDMUFA</AWSAccessKeyId>
              <Shared>
                <Keywords>{keywords}</Keywords>
                <SearchIndex>Music</SearchIndex>
              </Shared>
            </mx:request>
          </mx:operation> 
          <mx:operation name="ItemLookup" resultFormat="e4x" result="showItemLookupResults(event)" fault="{faultShow(event)}">
            <mx:request>
              <AWSAccessKeyId>####################</AWSAccessKeyId>
              <Shared>
                <ItemId>{currentItem.ASIN}</ItemId>
                <ResponseGroup>ItemAttributes,Images,Tracks,EditorialReview</ResponseGroup>
              </Shared>
            </mx:request>
          </mx:operation>
        </mx:WebService>

       
        <mx:Binding source="txtKeywords.text" destination="keywords" />
        <mx:Binding source="dgItems.selectedItem" destination="currentItem" />
        <mx:VBox>
            <mx:HBox>
            <mx:Label text="Search Music:"/>
            <mx:TextInput id="txtKeywords" width="181" enter="sendRequest()"/>
            <mx:Button x="288" y="10" label="Search" click="sendRequest()"/>
          </mx:HBox>
          <mx:DataGrid x="10" y="38" width="600" height="300" id="dgItems" dataProvider="{itemResults}" change="{getAmazonItemInfo()}" >
            <mx:columns>
              <mx:DataGridColumn headerText="Artist" labelFunction="getItemArtist" width="100" />
              <mx:DataGridColumn headerText="Title" labelFunction="getItemTitle" />
              <mx:DataGridColumn headerText="Label" labelFunction="getItemLabel" width="100" />
              <mx:DataGridColumn headerText="ASIN" dataField="ASIN" width="90" />
            </mx:columns>
          </mx:DataGrid>

          <mx:Canvas x="10" y="346" width="600" height="320" borderStyle="solid" backgroundColor="#EFEFEF" backgroundAlpha=".5">
            <mx:Image id="imgAlbumCover" x="10" y="60" width="200" height="200" scaleContent="true"/>
            <mx:Label x="218" y="10" width="362" fontSize="11" fontWeight="bold" id="lblArtistTitle" />
            <mx:Label x="218" y="41" text="Orginal Release Date:" fontSize="11"/>
            <mx:Label x="369" y="41" id="lblReleaseDate" fontSize="11" text="{currentItemDetails.*::ItemAttributes.*::OriginalReleaseDate}"/>
            <mx:Label x="218" y="69" text="Number of Discs:" fontSize="11"/>
            <mx:Label x="337" y="69" id="lblNumberDiscs" text="{currentItemDetails.*::ItemAttributes.*::NumberOfDiscs}" fontSize="11"/>
            <mx:Label x="218" y="97" text="Label:" fontSize="11"/>
            <mx:Label x="270" y="97" id="lblLabel" fontSize="11" text="{currentItemDetails.*::ItemAttributes.*::Label}"/>
            <mx:Label x="218" y="125" text="ASIN:" fontSize="11"/>
            <mx:Label x="266" y="125" id="lblASIN" fontSize="11" text="{currentItemDetails.*::ASIN}"/>
            <mx:Label x="218" y="152" text="Editorial Reviews:" fontSize="11"/>
            <mx:TextArea id="txtReview" x="218" y="179" width="362" height="120" backgroundAlpha="0.0" editable="false" wordWrap="true"/>
          </mx:Canvas>
        </mx:VBox>
      </mx:Application>

       

      ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ---------------------------

       

      I got error too when accessing WSDL from www.webservicex.net, and has different error from Amazon WSDL, here's the error:

      [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
          at mx.rpc::Responder/fault()
          at mx.rpc::AsyncRequest/fault()
          at DirectHTTPMessageResponder/securityErrorHandler()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/redirectEvent()

       

      And here's the code for using webservicex.net:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          horizontalScrollPolicy="auto" verticalScrollPolicy="auto" x="0" y="0" width="473" height="314">
        <mx:Script>
          <![CDATA[
          import mx.events.ValidationResultEvent;
          import mx.validators.Validator;
          import mx.validators.ValidationResult;
          import flash.sampler.NewObjectSample;
          import mx.rpc.events.ResultEvent;
          import mx.controls.Alert;
              
          private function sendRequest():void
          {
            Security.allowDomain("*");
            cek_Email.IsValidEmail.send();    
          }

       

          private function cekEmail(res:ResultEvent):void {
            if(res.result)
              Alert.show("Email Valid!");
            else
              Alert.show("Email not Valid!");
          }   
          
          private function handleValid(eventObj:ValidationResultEvent):void {
            if(eventObj.type==ValidationResultEvent.VALID)   
              // Enable Submit button.
              Submit.enabled = true;
            else
              Submit.enabled = false;
          }
         
          private function emailValid(eventObj:ValidationResultEvent):void {
            if(eventObj.type==ValidationResultEvent.VALID)   
              // Enable Submit button.
              Submit.enabled = true;
            else
              Alert.show("Wrong E-Mail Format!");
          }   
         
          ]]>
        </mx:Script>


        <mx:WebService id="cek_Email" wsdl="http://www.webservicex.net/ValidateEmail.asmx?WSDL"
          showBusyCursor="true" >
             <mx:operation name="IsValidEmail" resultFormat="object" result="cekEmail(event)">
            <mx:request>
              <Email>{edit_Email.text}</Email>
            </mx:request>   
          </mx:operation>   
        </mx:WebService>

       

        <mx:Validator id="reqValid" required="true"
          source="{textArea_Msg}" property="text"
          valid="handleValid(event)" invalid="handleValid(event)"/>
         
        <mx:EmailValidator source="{edit_Email}" property="text"
          trigger="{Submit}" triggerEvent="click"
          valid="emailValid(event)" invalid="emailValid(event)"/>
            
        <mx:Panel width="473" height="314" layout="absolute" id="Panel_Login" title="Contact Us" y="0" x="0">
        </mx:Panel>   
        <mx:Form x="15" y="29">
          <mx:Text width="100%" text="If you had any problem in using this website, you can leave your messages! You can ask anything about this website too!"  textAlign="center"/>
          <mx:FormItem label="Your E-Mail Address : " required="true">
            <mx:TextInput id="edit_Email" width="275"/>
          </mx:FormItem>    
          <mx:FormItem label="Subject : " >
            <mx:TextInput id="edit_Subject" width="275"/>
          </mx:FormItem>         
          <mx:FormItem label="Your Message :" required="true">
            <mx:TextArea x="124" y="120" id="textArea_Msg" height="94" width="275"/>
          </mx:FormItem>
          <mx:FormItem>
            <mx:Button x="191.5" y="232" label="Send" id="Submit" click="sendRequest();"/>   
          </mx:FormItem>
          <mx:Text width="100%" color="red" text="* is required field" />
        </mx:Form>
      </mx:Application>

       

      Enviroment that i use:

      - OS : M. Vista Bussiness

      - FB : Flex Builder 3.0

      - Flash Player: Adobe Flash Player 9.0.124.0

      - Database : MySQL that embed in XAMPP

      - Server : XAMPP 1.6.7 (for further work, i will published this Flex Application to a Web Server)

       

      Is this because of the Vista Security or Flash Player Security??? I try to make my Flex Application (same source code) in Win XP, and it has same error!!

       

      Can anybody help me???!! I've been searching this error since 4months ago, and still don't know the solution...

       

      Thx a lot!!

       

      Indra