2 Replies Latest reply on Mar 20, 2012 2:17 AM by Praful_Comp

    how to call function in web service using <HTTPService> component

    Praful_Comp

      Hi ,

      i need to call xyz function from  webservice which takes 2 parameter as email and password and will return object

       

      how to do that?

      please help .

       

      this is my code

       

       

      <fx:Script>
        <![CDATA[
         import mx.rpc.events.FaultEvent;
         import mx.rpc.events.ResultEvent;
         import mx.rpc.soap.Operation;
         import mx.rpc.soap.SOAPFault;
         import mx.utils.Base64Encoder;
         private var getdata:Operation;
        
         private function authAndSend(service:HTTPService):void    
         {     
          var encoder:Base64Encoder = new Base64Encoder();            
          encoder.insertNewLines = false;            
          encoder.encode("username:password"); 
          service.headers = {Authorization:"Basic " + encoder.toString()};
          service.send();
             
         }
        

        
         
         private function resultHandler(event:ResultEvent):void        
         {
        

       

             var webresult:String=event.result.toString();
         
         }
        
         private function resultFailed(event:FaultEvent):void
         {
          var err:String = event.fault.toString(); 
         
         }
        
        
         
        ]]>
       
      </fx:Script>

       


      <fx:Declarations>
       
        <s:HTTPService id="service" url="web service url"
              resultFormat="xml" result="resultHandler(event)">
        
        <s:request xmlns="">
          <Email>{"parameter1"}</Email>
          <Password>{"parameter2"}</Password>
         </s:request>
        
        </s:HTTPService>
       
        </fx:Declarations>

       

      <s:Button id="button"

          

           label="call service"

          

           click="authAndSend(service)" />

        • 1. Re: how to call function in web service using <HTTPService> component
          Patel Bharat Level 2

          Use this:

           

           

            private function authAndSend(service:HTTPService):void    

             {   

                     service.send();

            }

           

           

          <s:HTTPService id="service" url="web service url"

                  resultFormat="xml" result="resultHandler(event)">

            

                 <s:request xmlns="">

                        <Email>{username.text}</Email>

                        <Password>{password.text}</Password>

                  </s:request>

            

          </s:HTTPService>

          • 2. Re: how to call function in web service using <HTTPService> component
            Praful_Comp Level 1

            Hi ,

             

                 authAndSend( ) is not the function defined in web service , I am using this function for web service validation .

            there is function xyz( ) defined in web service , that i need to call through following code , how to do that ?

            please help.

                

             

             

            <fx:Script>
              <![CDATA[
               import mx.rpc.events.FaultEvent;
               import mx.rpc.events.ResultEvent;
               import mx.rpc.soap.Operation;
               import mx.rpc.soap.SOAPFault;
               import mx.utils.Base64Encoder;
               private var getdata:Operation;
              

            //function for web service validation
               private function authAndSend(service:HTTPService):void    
               {     
                var encoder:Base64Encoder = new Base64Encoder();            
                encoder.insertNewLines = false;            
                encoder.encode("username:password"); 
                service.headers = {Authorization:"Basic " + encoder.toString()};
                service.send();
                   
               }
              

              
               
               private function resultHandler(event:ResultEvent):void        
               {
              

             

                   var webresult:String=event.result.toString();
               
               }
              
               private function resultFailed(event:FaultEvent):void
               {
                var err:String = event.fault.toString(); 
               
               }
              
              
               
              ]]>
             
            </fx:Script>

             


            <fx:Declarations>
             
              <s:HTTPService id="service" url="web service url"
                    resultFormat="xml" result="resultHandler(event)">
              
               
              </s:HTTPService>
             
              </fx:Declarations>

             

            <s:Button id="button"

                

                 label="call service"

                

                 click="authAndSend(service)" />