HTTPService Error
When I am activating my HTTPService POST, I am getting this error:
[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost/server/secondPHP.php" errorID=2032]. URL: http://localhost/server/secondPHP.php"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
at mx.rpc::Responder/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
at mx.rpc::AsyncRequest/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.a s:113]
at DirectHTTPMessageResponder/errorHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\messa ging\channels\DirectHTTPChannel.as:410]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I am POSTing to a PHP file that looks like this:
<?php
$method = $_POST["method"];
if ($method == "ADD_FRIEND") {
$xml = new SimpleXMLElement('http://localhost/server/myxml.xml', null, true);
$xml->Users->addChild("Friend", "friend");
$xml->asXML('http://localhost/server/myxml.xml');
$returnValue = "Friend Added";
print($returnValue);
?>
I have no idea what the error message means. If anyone could help that would be great!
This is the security error, when you are accessing a file
from another webserver and the webserver has no crossdomain.xml in
his root.
The flashplayer runs in a sandbox which didn´t allow
direct access on other webserver locations (it is different if your
are running your debugger).
2 solutions:
- put a crossdomain.xml on the other webserver
- get the data from your webserver via a server script (for
example: with a php script)
best regards
kcell
Similar Messages
-
HTTPService error handling question
When i am using HTTPService for Flex-PHP communication i set
HTTPService's 'fault' property which handles error event. So
basically if i have HTTPService set up like this:
<mx:HTTPService id="test" url="
http://localhost/test/test.php"
contentType="application/xml" useProxy="false" method="POST"
fault="httpServiceError(event)">
</mx:HTTPService>
Then 'httpServiceError' method is fired in case of
HTTPService error. What i would like to do in httpServiceError
method is trace the id of the failed HTTPService. I tried with:
public function httpServiceError(evt:FaultEvent):void{
trace(evt.currentTarget.id);
But soon realized that FaultEvent doesn't conatin
'currentTarget' property so this failed. What's the correct way to
find out id of the failed HTTPService?
thanks in advance,
best regardsWhich version of flex are you on?
I'm not sure about version 2 but in Flex 3 fault event does
have currentTarget property. What do you get in the trace if you
just say event.currentTarget?
from the docs:
The FAULT event type.
The properties of the event object have the following values:
Property Value
bubbles false
cancelable true, calling preventDefault() from the associated
token's responder.fault method will prevent the service or
operation from dispatching this event
currentTarget The Object that defines the event listener that
handles the event. For example, if you use
myButton.addEventListener() to register an event listener, myButton
is the value of the currentTarget.
fault The Fault object that contains the details of what
caused this event.
message The Message associated with this event.
target The Object that dispatched the event; it is not always
the Object listening for the event. Use the currentTarget property
to always access the Object listening for the event.
token The token that represents the call to the method. Used
in the asynchronous completion token pattern.
ATTA -
HTTPService Error after waiting
Hi.
I've got a strange error using both HTTPService class and
URLLoader class: the error happens when the server is slow and the
service need to wait without getting data for a while
Trying using the SWF player, in local, this happens about 30
seconds after the request.
With an SWF in a browser this happens about 2 minutes after
the request.
The error I get is a generic Stream Error #2032 without any
informations about the couse.
Thank you for help.var loginService:HTTPService = new HTTPService();
login.addEventListener(FaultEvent.FAULT, handleFault);
loginService.url = "
http://localhost/login?req=login&username=user&password=pass&TS="+(new
Date()).time;
loginService.send();
I also tried to use URLVariables as send method params.
The result data doesn't matter, it always happens when the
server doesn't send any bytes and doesn't close the connection, as
it 's still computing the request. -
Hi!
I encountered the following problem with HTTPService in AIR app. Here is a code:
RequestAccountsHTTP.url = File.applicationStorageDirectory.resolvePath("db/accounts.xml").nativePath;
RequestAccountsHTTP.send();
Under Windows XP everything works fine, but under Mac OS Snow Leopard following error occur.
[RPC Fault faultString="HTTP request error"
faultCode="Server.Error.Request"
faultDetail="Error: [IOErrorEvent type="ioError"
bubbles=false cancelable=false eventPhase=2
text="Error #2032: Stream Error. URL: app:/Users/svp/Library/Preferences/com.myapp/Local%20Store/db/accounts.xml" errorID=2032]. URL: /Users/svp/Library/Preferences/com.myapp/Local Store/db/accounts.xml"]
I have Flex Builder 3, AIR 1.5.3, sdk 3.5 on both OS.
I would be glad of any help. Thanks.I solved it by replacing .nativePath with .url
-
Hi all,
I'm new to flex and actionscript and have been trawling
Google trying to find an example but I'm having no luck. What I'm
looking for is to return an error when my HTTPservice can't get a
connection to the file its calling. Does have any ideas or can
somebody point me towards an example that a complete novice will
understand.
ThanksI just put the actionscript ahead of the httpservice tags and
it seemed to work for me - well the fault came up!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
pageTitle="Report Register ver 1.0"
borderStyle="solid"
backgroundGradientColors="[#FFFFFF, #FFFFFF]"
defaultButton="{submit}"
>
<!--Actionscripts-->
<mx:Script>
<![CDATA[
import mx.events.ValidationResultEvent;
import mx.validators.Validator;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
public function httpFault(event:FaultEvent):void
Alert.show("Error! No Connection!")
private var imgBgrd:Class;
/* formats the DateField to DD-MMM-YY */
private function formatDate(date:Date):String {
return dmconv.format(date);
/* clears the text from inputs on the top of the form and
resets error strings */
private function clearInputsTop():void
faultDescInput.text = "";
dateModInput.text = "";
repDescInput.text = "";
repCode1Input.text = "";
assignedToInput.text = "";
commentsInput.text = "";
reportedByInput.text = "";
faultDescInput.errorString = "";
dateModInput.errorString = "";
repDescInput.errorString = "";
repCode1Input.errorString = "";
assignedToInput.errorString = "";
commentsInput.errorString = "";
reportedByInput.errorString = "";
/* clears the text from inputs on the bottom of the form and
resets error strings*/
private function clearInputsBottom():void{
repCode2.text = "";
repCode2.errorString = "";
/*validates the text input before sending to the server*/
private var vResult:ValidationResultEvent;
private function validateAndSubmit():void
//Validate the required fields
vResult = repCode1.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = repDesc.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = faultDesc.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = dateMod.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = assignedTo.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = reportedBy.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
vResult = comments.validate();
if (vResult.type==ValidationResultEvent.INVALID)
return;
//sends the data to the server
userRequest.send();
//visually alerts user that the table has been updated
Alert.show("Report Register updated!");
//clears input fields to start again
clearInputsTop();
//resets the focus to the top field
resetFocus();
private function
handleValid(event:ValidationResultEvent):void
if(event.type==ValidationResultEvent.VALID)
submit.enabled = true;
else
submit.enabled = false;
//sets the focus to the first input on the form
private function resetFocus():void
focusManager.setFocus(repCode1Input);
//clears the datagrid
private function clearGrid():void
myDataGrid.dataProvider = null;
]]>
</mx:Script>
<!--calls php file to send data to oracle database-->
<mx:HTTPService
id="userRequest"
url="
http://145.1.12.116/xampp/test/postData.php"
useProxy="false"
method="POST"
fault="httpFault(event)"
>
<mx:request xmlns="">
<ReportNumber>{repCode1Input.text}</ReportNumber>
<ReportName>{repDescInput.text}</ReportName>
<Date1>{dateModInput.text}</Date1>
<Users>{assignedToInput.text}</Users>
<Fault>{faultDescInput.text}</Fault>
<RUser>{reportedByInput.text}</RUser>
<Comments>{commentsInput.text}</Comments>
</mx:request>
</mx:HTTPService>
<!--calls php file to pull data from oracle database-->
<mx:HTTPService
id="userRequest2"
url="
http://145.1.12.116/xampp/test/getData.php"
useProxy="false"
method="POST"
fault="httpFault(event)"
>
<mx:request xmlns="">
<repCode2>{repCode2.text}</repCode2>
</mx:request>
</mx:HTTPService>
... -
I have a HTTPService that send user data via POST to
authenticate. If I start the application from Flexbuilder (press
run) erverything works fine. But if I export a release build and
try to run the swf from bin-release, I get the following error
message:
faultCode:Channel.Security.Error faultString:'Security error
accessing url' faultDetail:'Destination: DefaultHTTP'
Can anybody tell me how to fix it?
Thank youThe crossdomain policy is guaranteed to eat up your time. The
latest version of the flash player made this even harder by
requiring the port 843 for socket connections. Don't get me wrong
it's all good security wise, but until it works it can be a pain.
Try this is a crossdomain.xml file:
<?xml version="1.0" ?>
<cross-domain-policy>
<!-- use this directive to open the cross domain policies
to unrestricted access
-->
<site-control permitted-cross-domain-policies="all"/>
</cross-domain-policy>
Also have a read of this article:
http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.html.
It's long, but worth it. -
HTTPService error: Access of undefined property ...
For some reason, I get the error message "Access of undefined
property" for each element in the request ... and I only get the
error messages if the HTTPService is placed in an MXML Component
that is referenced from the main application. I don't get the error
messages, however, if the service is placed in the main
application.
What am i missing?
Here's my httpservice code:
<mx:HTTPService id="userRequest" url="
http://www.pixeldose.com/guestbook/comments.php"
useProxy="false" method="POST">
<mx:request xmlns="">
<username>{username.text}</username>
<emailaddress>{emailaddress.text}</emailaddress>
<website>{website.text}</website>
<comments>{comments.text}</comments>
</mx:request>
</mx:HTTPService>
Thanks in advance.
pixelflipI'm guessing that username, emailaddress, website and
comments are all variables in your application - so they won't be
in scope when you're in your MXML component.
You could
a) make all of these properties in your component and bind
them in your applciation.
b) make a single object with all these properties, make that
object a public property in your component and bind the object from
your application.
c) make a bindable variable in your component called
myApplication = Application.application as Application, and add
that to the front of your bindings.
d) make an public XML property in your component and define
the XML literal in your application.
e) put the HTTPService in your application.
Tim -
Hi all,
I am doing an application to get data from the server using
HTTPService.
I have an arraycollection containing all vehicle id's , For
each vehicle id , contains many vehicles with different colors. i
have to pass each vehicle id to server to get the image urls for
all vehicle images of that vehcle number.
so i am sending a query with vehcle id using httpservice, and
on result event of HTTPService, i am storing that urls in an array
and again executing HTTPService.send with different vehicle id URL.
This is working fine , if all urls execute successfully.
My problem is , suppose any time for any vehicle id query
fails , HTTPService Fault event is executing, After this i am not
able to continue sending url's for other vehicles id. My
application is stoped thier.
Since i am executing the next vehicle id query on Result
event. If Fault event raises how to ignore that and execute
further.
I am placing my code here.
public var vehicle_arr:ArrayCollection=new ArrayCollection;
public var cnt:int =0;
// vehicle_arr contains all vehicle numbers, for each vehicle
number there are different vehicle images are their,
// i have to pass this vehicle_id to get image url 's of that
vehicle number from the server.
public function getImgPath():void{ imgPathUrl="
http://www.xyz.com/flashhandler.aspx?Query=exec
dbo.viewGetVehicles ‘"+vehicle_arr[cnt].vehicle_id+"’"
var token:AsyncToken = AsyncToken(ImgPathsrv.send());
token.addResponder(new TokenResponder(getPhotoPath));
public function getPhotoPath(event:ResultEvent ) :void{
imgPath_arr=ImgPathsrv.lastResult.NewDataSet.Table
for(var i:int=0;i<imgPath_arr.length;i++){
img_arr.addItem({image:imgPath_arr
.PhotoPath});
cnt++;
if(cnt<vehicle_arr.length){
getImgPath();
<mx:HTTPService id="ImgPathsrv" url="{imgPathUrl}"
showBusyCursor="true" />
// for token responder class i created a actionscript file
which i am calling above.
package ascript
import mx.controls.Alert;
import mx.rpc.IResponder;
import mx.rpc.events.FaultEvent;
* A simple responder that will call the result function
specified but
* handles any fault by simply raising an Alert with the
specified title.
public class TokenResponder implements IResponder
private var resultHandler:Function;
private var faultTitle:String;
public function TokenResponder(result:Function,
faultTitle:String=null)
super();
resultHandler = result;
this.faultTitle = faultTitle;
public function result(data:Object):void
resultHandler(data);
public function fault(info:Object):void
//the info object from an AsyncToken is always a FaultEvent
Alert.show(FaultEvent(info).fault.toString(), faultTitle);
Any one please help me how to ignore fault for that url and
continue sending other url's to the same httpservice.
Thanks in advance
Regards
AvanthikaHi Avantika,
You might want to put your code inside the ' try' block and
'catch' any raised exceptions within you own code. 'Finally' you
can continue to send other URLs to the same HTTPService, even when
one of the URLs result in a fautl.
You can read more about the try...catch...finally blocks here
http://livedocs.macromedia.com/flex/2/langref/statements.html#try..catch..finally
It's pretty much the exact thing we use in Java for handling
exceptions.
Hope it helps.
~Shishir -
Error #1096 fault(Client.CouldNotDecode)
Ever since i updated my Flash Player plugin for Firefox 3 my
application keeps reports the following mx:HTTPService error #1096
fault(Client.CouldNotDecode) This issue is only in FireFox but in
Internet Explorer I have no problems bringing up the data. Both
browsers
have the latest version of Flash. When i test my code on a
older version of the flash plugin for FireFox it works. Any ideas
as to why. The XML is properly formatted with no errors.
The funny thing is it all works perfectly in Internet
Explorer Why is this. Is this a bug in the FlashPlayer?
Also my XML is properly formatted.What do you get when you print $ymessage to file in PHP, to see what it is?
What do you get when you trace userRequest.lastResult.games.game?
What does the PHP return outside of Flex?
If this post answered your question or helped, please mark it as such. -
Error loading data from an XML file using HTTPService
Hello All,
I have a runtime error that has got me beat at the moment I am building an App in Flash Builder 4 to run on AIR.
The error is as follows: TypeError: Error #1009: Cannot access a property or method of a null object reference.
What i'm Trying to Do:
I have 2 DropDownList controls, the first is populated with country names and the other with language options. All the 1st DropDownList control does
is set an image control to display the country flag and enable the 2nd DropDownList.
The 2nd DropDownList sets the langCode variable equal to the chosen language code. I then call the language function and pass it langCode. Using this variable, I build up the string
so that langFilePath will be equal to the XML file (which is "Lang_GBR.xml") location on my desktop and then call the HTTPService.
As soon as the language function is called, the runtime error occurs and highlights the line with btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
where I try to assign the button label with a new value from the XML file.
I suspect this may be a trivial error but I just can't see it at the moment.
Any help or guidance would be appreciated. Thanks
Code:
<fx:Script>
<![CDATA[
[Bindable]
public var langFilePath:String;
public var langDir:File = File.desktopDirectory;
public var langCode:String;
public function countrySelect_changeHandler(event:IndexChangeEvent):void
switch (countrySelect.selectedItem)
case ('United Kingdom'):
trace("Item Selected was: "+ countrySelect.selectedItem);
img_countryFlag.source = AngolaFlag;
break;
case ('France'):
trace("Item Selected was: "+ countrySelect.selectedItem);
img_countryFlag.source = AustraliaFlag;
break;
default:
break;
langSelect.enabled = true;
trace("1st dropdownbox");
public function langSelect_changeHandler(event:IndexChangeEvent):void
switch (langSelect.selectedItem)
case ('English'):
trace("Language Selected was: "+ langSelect.selectedItem);
langCode = "Lang_GBR";
break;
case ('French'):
trace("Language Selected was: "+ langSelect.selectedItem);
langCode = "Lang_FRA";
break;
language(langCode);
public function language(aParam:String):void
trace("Code Was: " + aParam);
trace("Lang dir: " + langDir.nativePath);
langFilePath = langDir.nativePath + "/" + aParam + ".xml";
trace("File to load: " + langFilePath);
trace("loadLangFile.url: " + loadLangService.url);
loadLangService.send();
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="loadLangService" url="{langFilePath}"/>
</fx:Declarations>
<s:DropDownList x="10" y="201" id="countrySelect" prompt="Please Select Your Country" width="274" enabled="true" change="countrySelect_changeHandler(event)">
<s:DropDownList x="10" y="348" id="langSelect" prompt="Please Select Your Language" width="274" enabled="false" change="langSelect_changeHandler(event)">Don't sure about your XML structure, but for now i see the problem here between this 2 lines of code:
loadLangService.send();
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
Think data that your httpService should receive just can't go so fast to populate the lastResult before you call it in the next line
Try adding a result listener to your service before you send it:
loadLangService.addEventListener(ResultEvent.RESULT, handler);
loadLangService.send();
function handler(event:ResultEvent):void {
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu; -
Error while issuing an httpService from a local swf
We have a swf that includes a Flex HTTPService call to check for
tomcat status. This call is resulting to below error:
Error #2028: Local-with-filesystem SWF filefile:///C:/......./click.swfcannot access Internet URLhttp://localhost:8600/.../dummy.html."
We are able to get over this error by adding this click.swf as "Always Allow"
at http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.ht ml#119065
However, in production environment it is not feasible to do this manual step.
We would want to know if there is a way to let the flash player know that this is trusted
by modifying any config file of Flash player or flex.
Please suggest. Any pointers on resolving this is greatly appreciatedMake sure you use -use-network=true. Or AIR.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
Error while calling HTTPService
i am getting [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032"] error while trying to call a htttpservice.
the following is the code which i am using to call the httpservice. my flex app and the http service which i am trying to call is located on the same server. if i paste the URL in the browser and click enter i was able to retreive the data.
but when i use the same URL in the flex its not working. i tried using an application called HTTPanalyzer which logs all the http requests
made by all the applications.but i couldnt find the flex app making any call to the server at all. i.e. its not actually sending request at all.please help me
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.*;
import mx.collections.*;
import mx.managers.PopUpManager;
import mx.core.Application;
import mx.events.*;
[Bindable]
private function passKeys():void{
var params:Object={};
params["bu"]=bu.text.toUpperCase();
params["poid"]=poID.text.toUpperCase();
params["poget"]=Application.application.poadd.poMetaData.toXMLString();
Alert.show(http_createPO.url);
Application.application.mode="A";
http_createPO.send(params);
]]>
</mx:Script>
<mx:HTTPService id="http_createPO" showBusyCursor="true" url="http://xxxx.com/WEBLIB_FX_DOC.SM_FX_PO.FieldFormula.IScript_createPO" result="Application.application.getPO(event)" resultFormat="xml" fault="Alert.show(event.fault.toString())"/>
<mx:Button x="134" y="68" label="Create PO" id="createPO" click="passKeys()"/>
<mx:TextInput x="166" y="11" id="bu" keyUp="autocomplete(this.bu,event)" fontWeight="bold"/>
<mx:TextInput x="166" y="37" id="poID" text="Next" fontWeight="bold" maxChars="8"/>
</mx:TitleWindow>Thanks for the reply guys.
i had it working.i have not changed anything from the code perspective i tried deleting browser cache and server cache.but its working only on some machines..any iddea guys? -
HTTPService fails to recognize HTTP Errors
I have a web service which, under certain (appropriate)
circumstances, will return with an HTTP status code of 404 and a
status description which provides a detailed error message.
Invoking this service from a variety of languages (perl, vba, c#,
java) results in the proper handling of such an event on the client
side.
However, with HTTPService (Flex 2 *AND* Flex 3), I appear to
have no access to the underlying status code and description.
Instead, my fault handler reveals only:
faultCode = Server.Error.Request
faultDetail = Error: [IOErrorEvent type="ioError"
bubbles=false cancelable=false eventPhase=2 text="Error #2032:
Stream Error. URL:
http://localhost/myUrl"
URL:
http://localhost/myUrl
faultString = HTTP request error
Searching the web, this appears to be a known limitation of
HTTPService, and *MANY* flex developers are complaining about it.
Yet the recommended workaround is to always return 200 from the web
service and simply embed a useful error message in the returning
payload. This works, but ruins things for the rest of the non-flex
consumers whose native http request objects correctly handle
things. And of course, it doesn't work if we don't control the web
service.
Can someone from ADOBE please weigh in here? If this is known
behavior, why, and what can be done to correct it?I understand your frustration, but unfortunately it is not
something that Flex can control. It's a limitation of the browser
plugin-APIs exposed to the Flash Player. We're hoping to work
through these issues but it's a long process.
Could you possibly detect that the Flash Player is making the
request and conditionally use a 200 status code, allowing the
non-200 status codes to be used for other clients?
If you do not control the status code, then another work
around is to use a proxy to do this status translation for you. If
you do not wish to develop your own proxy for this issue, note that
the ProxyService originally from LCDS has been exposed through the
new BlazeDS offering - this project as you may be aware has been
announced as an open source effort and the beta is on Adobe Labs.
http://labs.adobe.com/technologies/blazeds -
Why HTTPService is throwing error when there is two or less rows of data ?!
Hi guys,
I have an issue with HTTPService which is this.
I'm using HTTPService to retrieve data from SQL database, and to display those data in datagrid.
Basically MXML and script is like this :
example code ---------------------------------------------------------------------
<mx:HTTPService id="readRequestC"
method="POST"
useProxy="false"
url="http://www.mydomain.com/read_record.php"
result="showActiveAlerts(event)">
</mx:HTTPService>
private function showActiveAlerts(e:ResultEvent):void
C_activealerts_AC = e.result.patientalert.alert
end of code ------------------------------------------------------------------------
C_activealerts_AC - array collection is bound to data grid
I'm using this read_record.php file to retrieve data from database :
example code ---------------------------------------------------------------------
<?php
define( "DATABASE_SERVER", "xxx" );
define( "DATABASE_USERNAME", "xxx" );
define( "DATABASE_PASSWORD", "xxx" );
define( "DATABASE_NAME", "xxx" );
//connect to the database.
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
$Query = "SELECT * FROM patientalert";
$Result = mysql_query( $Query );
// ----------------------------------- xml is constructed here -------------------
$Return = "<patientalert>";
while ( $User = mysql_fetch_object( $Result ) )
$Return .= "<alert>
<idstaff>".$User->idstaff."</idstaff>
<idpatient>".$User->idpatient."</idpatient>
<idalerttype>".$User->idalerttype."</idalerttype>
<idalertstatus>".$User->idalertstatus."</idalertstatus>
<timestampappear>".$User->timestampappear."</timestampappear>
<timestampproceed>".$User->timestampproceed."</timestampproceed>
<position>".$User->position."</position>
<mobileid>".$User->mobileid."</mobileid>
</alert>";
$Return .= "</patientalert>";
mysql_free_result( $Result );
print ($Return)
?>
end of code ------------------------------------------------------------------------
This php file above is creating nice XML file which I'm reading with HTTPService. Everything is working fine when there is a lot of data (at least several rows)
The point is, that data is changing constantly in SQL base, there can be 10 rows, but there can be 3 of them... and here is the problem.
When there is less than 2 row of data... an error appears :
TypeError: Error #1034: Can not convert type mx.utils::ObjectProxy@4011089 to type mx.collections.ArrayCollection....
I'm sure this problem is due to fact that when there is only one row in database we don't have several <alert> nodes in XML so it cannot be converted into ArrayCollection.
Do you have any idea how to prevent this ? How to convert one row of data from database to valid Array Collection... and what if there will be no data in the table... in that case I simply want to display no data in data grid !
Thanks for any help !!!>>>> Im imagine you're feeding the HTTPService lastResult into an array collection, and then binding that to the Datagrid.
yes indeed... I'm doing precisely that :
I've got an array collection
[Bindable]
private var C_activealerts_AC:ArrayCollection=new ArrayCollection()
which is bound to datagrid :
<mx:DataGrid dataProvider="{C_activealerts_AC}">
<mx:columns>
<mx:DataGridColumn headerText="Staff" dataField="idstaff"/>
<mx:DataGridColumn headerText="Patient" dataField="idpatient"/>
<mx:DataGridColumn headerText="Type" dataField="idalerttype"/>
<mx:DataGridColumn headerText="Status" dataField="idalertstatus"/> ...etc..
</mx:columns>
</mx:DataGrid>
and I'm pushing event.result to C_activealerts_AC, like this :
<mx:HTTPService id="readRequestC"
method="POST"
useProxy="false"
url="http://www.mydomain.com/read_record.php"
result="showActiveAlerts(event)">
</mx:HTTPService>
private function showActiveAlerts(e:ResultEvent):void {
C_activealerts_AC = e.result.patientalert.alert
Now... I'm looking at your solution but I'm not quite catching it ... you have
two results in HTTPService ? Compiler doesn't like this it's shouting 'result has been defined once' !
result="handleRequestC(event)"
result="showActiveAlerts(event)"
and what is this 'Datagrid' below... is it an id of my datagrid ?? hmm..
Datagrid.dataprovider = evt.result.patientalert.alert;
Could you please explain it a little more ?
I thought if there is one row of data, array collection will be feeded only with one object... apparently, like you say, it's not
Thanx -
Air HTTPService Stream Error #2032
Hi there,
I am currently creating an Air app which loads 1 or more xml on creation complete.
So what it does is, it searches for xml files in a given folder by looping over the contents in this folder, if it's an xml then it loads it using HTTPService, it then retrieves the xml data then moves the xml file to another folder, this repeats until all xml files have been loaded.
This is all working fine except sometimes not all xml files get loaded and I encounter the #2032 error, is this because I am loading multiple xml files one after the other in a loop?
This does not seem to happen if there is only one xml but two or more starts to get a bit temperamental.
Any help would be greatly appreciated, thank you,
FuyukoHi there, thanks for your reply. ok here is the code, when I instantiated the HTTPService object at the top as a private var it works 100% BUT now for some reason it tries to open the same xml three times for all three files! the first time it works, but the second and third time it errors(obviously!).
The code in red is the older code which I thought would be the way to do this but almost 50% of the time one of the files does not get loaded and instead gives me the dreaded #2032 error.....
private var fileName:String;
private var dir:File = new File("file:///C:/wamp/www/FileWatcher/Data");
private var processedLocation:File = new File("file:///C:/wamp/www/FileWatcher/Data/processed");
private var service:HTTPService = new HTTPService();
private function init():void
//get direcotry listing inside Data
dir.getDirectoryListingAsync();
//call function to retrieve the names of each file
dir.addEventListener(FileListEvent.DIRECTORY_LISTING, getFileName);
private function getFileName(event:FileListEvent):void
for each(var item:File in event.files)
//trace(item.name);
if(item.name!="processed" && item.name!="log.txt")
//set variable to the item name
fileName = item.name;
//call function to open this file and load the xml contents
getData(fileName);
private function getData(fileName:String):void
var service:HTTPService = new HTTPService();
var urlString:String = "http://localhost/FileWatcher/Data/"+fileName;
service.resultFormat="e4x";
service.url = urlString;
service.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void{resultHandler(e, fileName)});
service.addEventListener(FaultEvent.FAULT, function(e:FaultEvent):void{faultHandler(e, fileName)});
service.send();
private function faultHandler(evt:FaultEvent, fileName:String):void
var myDate:Date = new Date();
var formattedDate:String = dateFormatter.format(myDate);
var dateString:String = formattedDate+myDate.milliseconds;
var message:String = "Fault occurred at "+dateString+" The origin of the fault is "+evt.message;
trace("**********************ERROR**********************");
trace("Loading data for "+fileName+" was unsuccessful at "+dateString+"\r\n");
private function resultHandler(evt:ResultEvent, fileName:String):void
//trace("result is "+evt.result.toString());
//write data in to the database here
//get directory listings inside Data
var directory:File = new File("file:///C:/wamp/www/FileWatcher/Data");
directory.getDirectoryListingAsync();
//call function to move each file to the new location
Maybe you are looking for
-
Intel iMac won't recognize external display with Dynex mini-DVI adapter
I've got an original Intel iMac with a Mini-DVI connection on the back. I'm attempting to hook it up to an external display (a plasma screen, in fact). I picked up a Dynex Mini DVI to Video Adapter DX-AP100 for Apple. This connector has a mini-DVI co
-
Could not resolve br to a component implementation. ???
For some reason im getting an error: Could not resolve <br> to a component implementation. for this code which looks fine to me <s:RichText styleName="blueBackLabel" width="100%" height="35"> <s:content> mid-e
-
Tape1081 vs progressive?
I am wondering if I should upgrade my camera. I have an Hd1 mini dv 1080i Sony tape camera from 3 years ago. How big a difference is the quality of the new progressive HD cameras these days? The person who lends out the equipment says it is a huge di
-
Hi All, select * from v$version; BANNER Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production PL/SQL Release 11.1.0.7.0 - Production CORE 11.1.0.7.0 Production TNS for Linux: Version 11.1.0.7.0 - Production NLSRTL Versi
-
Firefox issue with SWC and sliders/radio
Hello, I am having an issue where my radios and sliders aren't showing up in Firefox. I have a Flash CS3 using AS3 inerface that I am exporting to a .swc file. The flash/swc uses the built in slider and radio buttons in it. I pull that swc into the l