1 Reply Latest reply on Nov 19, 2010 11:00 AM by alinator11

    URLRequest in Flex 4

    mvbaffa

      Hi,

       

      I've been working with flex 3 for a long time and now I am trying Flex 4. In my project I have to call WCF/JSON services.

       

      I am calling my services with URLRequest. IThe problem is that  can only call the service with the GET method.

       

      When I call the service like this, I receive an error:

       

      var loader:URLLoader = new URLLoader();                
      var header:URLRequestHeader = new URLRequestHeader("Content-Type", "application/json");                  
      configureListeners(loader);                  
      var request:URLRequest = new URLRequest("http://localhost/url.svc\method");                
      request.method = URLRequestMethod.POST;                
      request.requestHeaders.push(header);

       

      Even setting the method property of request my application is calling the service  with a GET method. I have to set the WebInvoke in the service to GET to succeed.

       

      By the way the same service is called by jQuery with the POST method and it works.

       

      Can you help me ???

       

      Thanks in advance

        • 1. Re: URLRequest in Flex 4
          alinator11 Level 2

          FYI, I had to open this in firefox to reply. There is no reply button in my IE version.

           

          Hi Mvbaffa,

           

          I recently had this same problem with the WebServices class. While the API indicates that I should be able to say:

           

          var service:WebService = new WebService();

          service.loadWebService(serviceWSDL);

          service.operation = operation;

          return service.send().result;

           

          You can't really. They are just teasing. LOL. What I had to do was to add an EventListener. Until I added an EventListener, I could watch my logs on Apache and see the SWF get the wsdl, but it would never parse it. Once I added an EventListener and Handler, everything ran fine.

           

          I don't know that the same thing is true with the URLLoader object but I would put my suspicions there. Try adding an EventListener and see if that helps: http://www.flash-db.com/Tutorials/loadingAS3/loadingData.php

           

          Cheers,

          Al