locked
Flex Application accessing php scripts in webcgi role is getting a security error RRS feed

  • Question

  • Hi,

       We have a Flex application which is deployed on MSAzure. As part of our requirement, we need our Flex code to write to blob storage on Azure. We are doing this via HTTP service calls to PHP scripts (standard code provided by Microsoft SDK for PHP). We are able to call this code via our Flex Application in Flash Builder and upload to our blob storage.

    However, when we try to do the same in Visual Studio we get an error Saying Secuiry error Accessing URL.  We are carrying out the following steps

    1. create webcgi role in Visual Studio. .NET

    2. Add our php scripts to the role. The PHP scripts run fine independently and can update the blob storage.

    3. Now added files from our Flex Application to the webcgi role.  Also added file crossdomain.xml for accessing across the web server.

    4. Set the start page, build and run the application.

    5. We can run our application, when it makes the HTTP Service call to PHP code, we get an error Security error accessing URL.

    Please advise.

     

     

    Wednesday, April 20, 2011 9:26 AM

Answers

  • Hello RG1967,

    You are using a Flex applicaion in a cgi web role and are experiencing the "Secuiry error Accessing URL" error in the Flex application.

    As far as I know, this error occurs mostly because the Flex application is sending request to an uri that belongs to another domain. But as you have mentioned, your php pages and the Flex application are in the same web site. So it will not be a corss domain problem.

    What I am wondering is that what the uri is actually being requested by the Flex application. Is the Flex application sending the request to the correct page? Please note that when your web site runs in compute emulator, the domain name will be the IP address 127.0.0.1 if you haven't assigned a host header.

    Thanks,


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:41 AM
    • Unmarked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    Thursday, April 21, 2011 8:56 AM
  • Hi Aparna,

    Can you let us know the steps involved in pointing our domain to the VIP of service?

    VIP is is the IP address when a role is deployed on the cloud. We can find it's value from the management portal. In order to use our a custom domain, we firstly need to own a domain. Then we can add a CNAME record (points to the VIP) using the management portal from the domain provider where you bought the domain from. See http://en.wikipedia.org/wiki/CNAME_record.

    When we debug our service on localhost, the IP address is 127.0.0.1. But please note there is also a port which is being used and may be changed to another value. We can specify a custom port number in the service definition file.

    <Endpoints>
        <InputEndpoint name="Endpoint1" protocol="http" port="8080" />
    </Endpoints>

    We can find the actual port being used in the address bar of the browser when the web site is debugging. I see that the Flex application is requesting http://127.0.0.1/blobcode1.php. I would suggest you input this address in browser and check if the target page is valid or not. It mostly to be a port issue.

    Thanks,


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    Monday, April 25, 2011 8:55 AM

All replies

  • Hello RG1967,

    You are using a Flex applicaion in a cgi web role and are experiencing the "Secuiry error Accessing URL" error in the Flex application.

    As far as I know, this error occurs mostly because the Flex application is sending request to an uri that belongs to another domain. But as you have mentioned, your php pages and the Flex application are in the same web site. So it will not be a corss domain problem.

    What I am wondering is that what the uri is actually being requested by the Flex application. Is the Flex application sending the request to the correct page? Please note that when your web site runs in compute emulator, the domain name will be the IP address 127.0.0.1 if you haven't assigned a host header.

    Thanks,


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:41 AM
    • Unmarked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    Thursday, April 21, 2011 8:56 AM
  •  

    Hello Wenchao,
        I am a Flex developer and am new to the Azure environment. I am not really aware of the host header. How can I assign a host header in my application?
     
    Regards
    Aparna
     
    Friday, April 22, 2011 12:24 PM
  • Hi Aparna,

    Yes you can assign a host header for your web site if you use multiple web sites in a web role (see Exercise 1: Registering Sites, Applications, and Virtual Directories). If there is only one web site in the web role, there is no need to use host header, you can directly point your the domain to the VIP of your service. Then you can access your web site via that domain.

    When debugging you service in compute emulator, you can edit the host file (normally your can find it within C:\Windows\System32\drivers\etc folder) and point a domain to 127.0.0.1.

    Thanks,


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Monday, April 25, 2011 1:58 AM
  • Hi Wenchao,

        My flex code is accessing the http service via the following code

    <fx:Declarations>

     

    <!-- Place non-visual elements (e.g., services, value objects) here -->
     

     

    <mx:HTTPService id="serviceGetOrPutDataFile" method="POST" resultFormat="e4x" url="http://127.0.0.1/blobcode1.php" result="onResultGetOrPutDataFile(event)"

    fault="onFaultGetOrPutDataFile(event)"

    />

     

    </fx:Declarations>

    I have only a single webrole webcgi role in which my flex and php scripts are placed.  Can you let us know the steps involved in pointing our domain to the VIP of service?

    Is there  any link available which explains the same?

     

    Regards

    Aparna

     

    Monday, April 25, 2011 8:39 AM
  • Hi Aparna,

    Can you let us know the steps involved in pointing our domain to the VIP of service?

    VIP is is the IP address when a role is deployed on the cloud. We can find it's value from the management portal. In order to use our a custom domain, we firstly need to own a domain. Then we can add a CNAME record (points to the VIP) using the management portal from the domain provider where you bought the domain from. See http://en.wikipedia.org/wiki/CNAME_record.

    When we debug our service on localhost, the IP address is 127.0.0.1. But please note there is also a port which is being used and may be changed to another value. We can specify a custom port number in the service definition file.

    <Endpoints>
        <InputEndpoint name="Endpoint1" protocol="http" port="8080" />
    </Endpoints>

    We can find the actual port being used in the address bar of the browser when the web site is debugging. I see that the Flex application is requesting http://127.0.0.1/blobcode1.php. I would suggest you input this address in browser and check if the target page is valid or not. It mostly to be a port issue.

    Thanks,


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Wednesday, April 27, 2011 3:42 AM
    Monday, April 25, 2011 8:55 AM