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");
var request:URLRequest = new URLRequest("http://localhost/url.svc\method");
request.method = URLRequestMethod.POST;
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
FYI, I had to open this in firefox to reply. There is no reply button in my IE version.
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.operation = operation;
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