Friday, February 05, 2010

Consume WCF and XML Web services using HTTPServices in Flex

Hi All,

I'd like to share with you this problem we faced in one of our projects, I was building a WCF/XML Web services Layer to be consumed by Mobile and Non-Microsoft Technologies such as FLEX / ColdFusion.

One of our team members was saying that when he was trying to consume our web services he wasn't able to get the results from our services layer.

I started to search why this happened only when when you try to get the data from a Flex Application, The solution is : the Flex only support HTTPServices and this means that the client only able to interact with the webservices either using HTTP GET or POST. and since web.config default configuration is : HTTP GET/POST is disabled by default and you will not be able to post parameters in the query string, here is the request from Flex:

http://www.MostafaElzogbhi.innovate/WSLayer/Service1.asmx/GetTestData?Id=10


What you need to do update the web.config by adding HTTP GET/POST protocols.

<system.web>

<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<system.web>

Hope this helps .Net and Flex developers all together.

Regards,
Mostafa arafa

No comments: