Tested SDK version: 0.5.0

We're trying to call our web service with HTTPService
(/org.apache.flex.net.HTTPService/) class to get some XML data. I am fairly
new to FlexJS, please guide me.

We've tried this following code to get the data from our web service:

public function DataAgent(url:String, success:Function, error:Function,
sendObject:String=null, method:String=HTTPService.HTTP_METHOD_POST)
{
        httpS = new HTTPService();
        httpS.method = method;
        httpS.url = url;
        httpS.contentData = sendObject;
        httpS.addEventListener("complete", onCompleteEvent);
        httpS.addEventListener("ioError", onIOError);
                        
        httpS.send();
}
                
private function onCompleteEvent(event:Event):void
{
        var xml:XML = new XML(event.target.data);
}
                
private function onIOError(event:Event):void
{
        org.apache.flex.html.Alert.show(event.target.url,
MyController.app.initialView);
}

With above codes I had these:

1. Working expectedly when run as SWF in browser
2. Not working at all when converted to HTML by FlexJS SDK
3. 'org.apache.flex.html.Alert' never fires when run as HTML
4. onCompleteEvent() throws error 'variable XML is undefined'!
5. I even don't know what is inside 'event' when run as HTML - alerting
'event' not works


Therefore I dig more with FlexJS 0.5.0 provided examples and in
'FlexWebsiteStatsViewer' example I noticed these following codes where
HTTPService calls in MXML tag:

<js:HTTPService id="service" method="POST">
        <js:LazyCollection id="collection">
                <js:inputParser>
                        <controllers:GAJSONInputParser />
                </js:inputParser>
                <js:itemConverter>
                        <controllers:GAStatsDataJSONItemConverter />
                </js:itemConverter>
        </js:LazyCollection>
</js:HTTPService>

After more investigation into the code/data-incoming, I felt:

1. GAJSONInputParser is receiving incoming data as String and therefore
giving a shape to the String by subStr etc.
2. GAStatsDataJSONItemConverter then returned String value by
GAJSONInputParser and converted things into object by parsing the String by
subStr etc.

I tried our URL call with this above way now. I noticed that I received XML
as String inside GAJSONInputParser class. So, here are the question I'm now
standing in front of:

1. Should we need to always use HTTPService in MXML tag - the way I
mentioned above?
2. If #1 is No, then what is failing in my earlier ActionScript codes (that
I've pasted in beginning of this post)
3. Why I am having 'variable XML is undefined' - FlexJS provides any API to
read XML object?
4. Do I need to parse an XML by String.substr way only? (as above example
parsing JSON String)
5. Why FlexJS Alert is not working when ran as HTML?



--
View this message in context: 
http://apache-flex-users.2333346.n4.nabble.com/FlexJS-HTTPService-for-XML-parsing-tp12094.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Reply via email to