Hi All,

i have made a servelt which returns details in xml format ,
this is servlet is working fine if am calling it from flex in static way
like this

<mx:HTTPService id="topSenders" useProxy="false" resultFormat="xml"  
method="POST" 
url="http://localhost:8080/Application/topSenderServlet?TYPE=4&amp;USER_ID=12";  
        result="serv_result(event);"/>


but if i tried to call the servlet like this


<mx:HTTPService id="topSenders" useProxy="false" resultFormat="xml"  
method="POST" url="{servletURL}"  
        result="serv_result(event);"/>


then it is not working , am not getting any error

here is the full code for my mxml file



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="init()">
        <mx:Script>
                <![CDATA[
                        import flash.net.sendToURL;
                        import mx.controls.Alert;
                        import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.xml.SimpleXMLDecoder;
            import mx.controls.Button;
            import mx.controls.Label;
            import mx.collections.ArrayCollection;
                        
                        [Bindable]
            public var expenses:ArrayCollection;
            
            [Bindable]
            public var userId:int;
            [Bindable]
                        public var servletURL:String;
            
            
            
            
                        
                        private function init():void{
                                userId = 12;
                                
servletURL="http://localhost:8080/Application/topSenderServlet?TYPE=4&amp;USER_ID="+userId;
                                Alert.show(servletURL);
                                topSenders.send();
                        }
             private function serv_result(evt:ResultEvent):void {
                /* Convert XMLNode to XMLDocument. */
                var xmlStr:String = evt.result.toString();
                var xmlDoc:XMLDocument = new XMLDocument(xmlStr);
                var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
                var resultObj:Object = decoder.decodeXML(xmlDoc);
                /* Assign the values... */
                
              expenses = new ArrayCollection();
              for(var i:int=0;i<resultObj.top.sender.length;i++){
                        Alert.show(resultObj.top.sender[i].phone);
                        
             }
         }
                        
            
                ]]>
        </mx:Script>
        

<!--<mx:HTTPService id="topSenders" useProxy="false" resultFormat="xml"  
method="POST" 
url="http://localhost:8080/Application/topSenderServlet?TYPE=4&amp;USER_ID=12";  
        result="serv_result(event);"/>-->

<mx:HTTPService id="topSenders" useProxy="false" resultFormat="xml"  
method="POST" url="{servletURL}"  
        result="serv_result(event);"/>

  </mx:Application>




thanking you in advance




Reply via email to