3 Replies Latest reply on Nov 23, 2008 11:58 PM by SujitG

    Flex web service consumer problem

      Hello guys!

      I have just started messing around with Flex, and I thought that a good practice would be trying to connect to one of the web services that my company offers developing a simple client on Flex.

      I used Flex Builder and found it really easy: With only a few lines of code a really nice GUI... impressive!

      So now lets show it to my colleagues...but UPS!

      I place the application under my local Tomcat and instead of retrieving data I get:

      [FaultEvent fault=[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"] messageId=null type="fault" bubbles=true cancelable=true eventPhase=2]

      After a lot of research I cannot make it work... I have read about crossdomain.xml, I have copied this file into my tomcat\webapps\ROOT folder allowing all domains:

      <?xml version="1.0"?>
      <!DOCTYPE cross-domain-policy SYSTEM " http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
      <allow-access-from domain="*" />
      <allow-http-request-headers-from domain="*" headers="*" />

      Because this crossdomain.xml should be on the server were my Flex client is placed, isn't it? I have read some articles, and they say that this XML has to be placed on the server which offers the web service. I think this cannot be possible, in that case I have to ask to my IT department to upload that file, and they for sure aren't going to allow that.

      Could you please help me? Why is the client working under Flex Builder and not when I deploy it on my Tomcat? And when I says deploy I mean that I have copied what Flex Builder generates on "bin-release" folder into the Tomcat's webapps folder.

      Thanks for your help in advance!
        • 1. Re: Flex web service consumer problem
          SujitG Level 2

          When you are running from Flex Builder, Flex Builder automatically adds your ..swf file to list of trusted files. So cross domain check is not made and you can access the web service. Where as when it is launched from the web server, cross domain check is made. You can use BlazeDS (Free and Open source J2EE application) and use Proxy service to request the web service. In this case you don't need a cross domain file to be uploaded in the web server when the web service is exposed.

          Hope this helps.
          • 2. Re: Flex web service consumer problem
            Pirlock Level 1
            Sure that helps!

            In fact I have already finished the client using finally BlazeDS. I am really happy about it, because my managers are really impressed with the final result, and they are considering using Flex in next developments.

            My only complain for the moment is that Flex hasn't got a PDF viewer component, and we have to do an ugly workaround using an iframe (which we have to show and hide to avoid overlapping with the SWF content). But I'm still completely fanatic about Flex!

            Thank you so much for your help and regards from Spain!
            • 3. Re: Flex web service consumer problem
              SujitG Level 2

              Yes, Flex rocks !
              Unfortunately there is no way to render PDF in Flash applications as of now. I think iframe is the way to go.

              Enjoy creating Rich Internet Applications.