Highlighted

Multiple calls using HTTPService

Hendriv

22-03-2009

Hi,

I am beginner with Flex.



My Flex application uses an HTTPService to communicate with a
server running php.



<mx:HTTPService result="WaitForAcqChangeComplete(event);"


fault="handleFault(event);"

id="HttpWaitForAcqChange"

resultFormat="e4x"


url="https://rekenaarxp/gsi/maintenance/acquisitions/waitforsomething.php"


useProxy="false"

contentType="application/xml"

>

<mx:request xmlns="">

</mx:request>

</mx:HTTPService>



I have written a php extension DLL that is called from the
php code. One of the functions I provide essentially puts the
calling thread to sleep until something server event happens. (This
is in my DLL, where i use the Windows WaitForMultipleObjects()
function).

Waiting here could take a long time, or potentially never
happen.



If the even happens, the call into the extension completes,
and the php page is provided back to the flex app, which

then calls the completion code for the HTTPSerivce.



This all works fine, until the flex application tries to make
another access to waitforsomething.php while a previous

access has still not completed. In this case,
waitforsomething.php doesn't get called at all. Only when the
previous call completes, does the next call come in.



By playing around, i notice that if i add
contentType="application/xml" to the HTTPService request, then it
all works

as expected, and i can have multiple calls to the server.
Remove it, and I am back to only ever having one call at

any time.



I realise that adding contentType="application/xml" is not
correct for what i am doing, but why does it make it work?

What is the correct solution to this type of problem? Am I
looking at some kind of cache issue?



Any help will be very much appreciated.

Replies

Highlighted

dersler

14-04-2009

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="
horizontal" horizontalAlign="left"
     backgroundGradientColors="
[0x000000,0x323232]"   
    applicationComplete="
srv.send()" viewSourceURL="srcview/index.html">

    <mx:NumberFormatter id="nf"/>
   
    <!-- resultFormat tells the HTTPService how to deserialize the result of the HTTP request.
         By default, the response is deserialized into an object graph. This allows you to navigate through
         the service result using the dot notation.
         You can also get the result as an XML document by specifying resultFormat="e4x" on the HTTPService.
         In that case, you can parse the document using E4X (ECMAScript for XML).
-->
    <mx:HTTPService id="srv" url="items.xml" resultFormat="e4x"/>

    <mx:Tree id="tree" dataProvider="{srv.lastResult}" labelField="@name"
        width="
300" height="100%"/>

    <mx:Form>
        <mx:FormItem label="Population:">
            <!-- e4x data binding expression -->
            <mx:TextInput text="{nf.format(tree.selectedItem.@population)}"/>
        </mx:FormItem>
        <mx:FormItem label="Capital:">
            <!-- e4x data binding expression -->
            <mx:TextInput text="{tree.selectedItem.@capital}"/>
        </mx:FormItem>
    </mx:Form>

    <mx:Style>
        FormItem {
            labelStyleName: formItemLabel;
        }
        .formItemLabel {
            color: #FFFFFF;
        }
    </mx:Style>
   
</mx:Application>