Flex XML HTTPservice
I've written an XML service in Zend Framework and I want to
parse the data to E4X/something else. I get back XML data something
like this:
quote:
<?xml version="1.0" encoding="UTF-8"?>
<root><Pname>caramba</Pname><Email>1</Email><DOB>4</DOB><Sex>1</Sex><Phone>1</Phone><Addre ss>caramba</Address><Photo>1</Photo><Enum>4</Enum></root>
I want to get each variable Pname, Email and so forth into
variable into Flex. How do I go about this?
Doc on using an HTTPService is here:
http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html
This includes lots of examples, including examples that use
XML as the data source with E4X.
More doc on working with E4X is here:
http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_03.html
hth,
matt horn
flex docs
Similar Messages
-
Flex's HTTPService dispatches a ResultEvent instead of a FaultEvent
Flex's HTTPService dispatches a ResultEvent instead of a FaultEvent
I would like to know when does Flex's HTTPService launches a ResultEvent and when does it dispatches a FaultEvent.
When the servers response contain a 401 http status code error (Unauthorized), the HTTPService is dispatches a ResultEvent instead of a FaultEvent. I would assume that it should dispatch a FaultEvent. Am I correct? If not please tell me.
The amazing thing is that when I'm running the application under the Flash Builder 4.7's Android Simulator, it does dispatch a FaultEvent, but when I run it on the device, it dispatches the ResultEvent. Why is this happening? Any ideas?I created an application to test what happens on both scenarios (Flash Builder's Simulator and Android Device) and compare the results. Next is the code.
Test application code
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
///////////////////////////// USING HIGH LEVEL COMPONENT (FLEX) //////////////////////////////////////////
* Checks if all the necesary data was entered by the user.
protected function configHandler(event:MouseEvent):void
textArea.text = "Connecting to server using a high level component";
configurationService.url = "http://10.0.0.221/api/v1/room/current/";
configurationService.headers.Accept = "application/json";
configurationService.send();
textArea.appendText("\n...");
* Handles the first phase (getting basic application information) of the configuration.
* Stores the retrieved data from the server and calls the second phase of the process.
protected function serviceResultHandler(event:ResultEvent):void
textArea.appendText("\n");
textArea.appendText("Entering serviceResultHandler \n");
textArea.appendText(" HTTP status code is: " + event.statusCode);
* Handles errors within the first phase (getting basic application information) of the configuration process.
protected function servicefaultHandler(event:FaultEvent):void
textArea.appendText("\n");
textArea.appendText("Entering servicefaultHandler \n");
textArea.appendText("HTTP status code is: " + event.statusCode);
///////////////////////////// USING LOW LEVEL COMPONENT (FLASH) //////////////////////////////////////////
* Checks if all the necesary data was entered by the user.
protected function config2Handler(event:MouseEvent):void
textArea.text = "Connecting to server using a low level component \n ...";
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://10.0.0.221/api/v1/room/current/");
request.requestHeaders = new Array( new URLRequestHeader('Accept','application/json'));
try {
loader.load(request);
} catch (error:Error) {
trace("Unable to load requested document.");
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(Event.OPEN, openHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
textArea.appendText("\n");
textArea.appendText("Entering completeHandler \n");
textArea.appendText("completeHandler: " + loader.data + "\n");
var vars:URLVariables = new URLVariables(loader.data);
textArea.appendText("The answer is " + vars.answer);
private function openHandler(event:Event):void {
textArea.appendText("\n");
textArea.appendText("Entering openHandler \n");
textArea.appendText("openHandler: " + event);
private function progressHandler(event:ProgressEvent):void {
textArea.appendText("\n");
textArea.appendText("Entering progressHandler \n");
textArea.appendText("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
private function securityErrorHandler(event:SecurityErrorEvent):void {
textArea.appendText("\n");
textArea.appendText("Entering securityErrorHandler \n");
textArea.appendText("securityErrorHandler: " + event);
private function httpStatusHandler(event:HTTPStatusEvent):void {
textArea.appendText("\n");
textArea.appendText("Entering httpStatusHandler \n");
textArea.appendText("httpStatusHandler: " + event);
private function ioErrorHandler(event:IOErrorEvent):void {
textArea.appendText("\n");
textArea.appendText("Entering ioErrorHandler \n");
textArea.appendText("ioErrorHandler: " + event);
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="configurationService"
result="serviceResultHandler(event)" fault="servicefaultHandler(event)"/>
</fx:Declarations>
<s:Button label="High Level" click="configHandler(event)"
horizontalCenter="100" top="20" />
<s:Button label="Low Level" click="config2Handler(event)"
horizontalCenter="-100" top="20"/>
<s:TextArea id="textArea"
left="20" right="20" top="{configButton.y + configButton.height + 20}" bottom="20"/>
</s:View>
Results on the Flash Builder Simulator
When pressing the "Low Level" button (URL Loader) the text on the text area was:Connecting to server using a low level component ... Entering openHandler openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2] Entering httpStatusHandler httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=401 responseURL=null] Entering ioErrorHandler ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://10.0.0.221/api/v1/room/current/" errorID=2032]
When pressing the "High Level" button (HTTPService) the text on the text area was:Connecting to server using a high level component ... Entering servicefaultHandler HTTP status code is: 401
Results on the Android device
When pressing the "Low Level" button (URL Loader) the text on the text area was:Connecting to server using a low level component ... Entering openHandler openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2] Entering httpStatusHandler httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=401 redirected=false responseURL=null] Entering completeHandler completeHandler:
When pressing the "High Level" button (HTTPService) the text on the text area was:Connecting to server using a high level component ... Entering serviceResultHandler HTTP status code is: 401
When I ran the app on the Flash Builder's Simulator, both components worked as expected, meaning that they dispatched a FaultEvent and an IOErrorEvent. On the Android device each component misbehaived, the first dispatching a ResultEvent and the second one an Event.COMPLETE event.
Notice that on both scenarios, both components percieve the correct HTTP status code.
I would assume that there is a problem with the runtime, right? I'd appreciate your comments on the matter. -
Flex, xml, and non-English characters
Hello! I have a Flex web app with AdvancedDataGrid. And I use httpService component to load some data to grid. The .xml file contains non-english characters in attributes (russian in my case) like this:
<?xml version="1.0" encoding="utf-8" ?>
<Autoparts>
<autopart DESCRIPTION="Барабан">
</Autoparts>
And when i run app, AdvancedDataGrid display it like "сПÐ". How can i fix it? I try to change encoding="utf-8" with some another charsets, bun unsuccesfully. Thank you.Try changing the xml structure by using CDATA instead of having the russian part as an attribute and see if that makes any difference.
What I meant is use something like this:
<?xml version="1.0" encoding="utf-8" ?>
<Autoparts>
<autopart>
<description><![CDATA[Барабан]]></description>
</autopart>
</Autoparts>
instead of the current xml. -
Hi all,
I am really new so please excuse my lack of knowledge. I have
a flex app that keeps track of a workout program progress. Each
user updates their stats each week.
So I have a section where a new member can be added. I have a
datagrid that is populated by an xml file along with a form to add
a new member. When I test the app it works, the new user is added
and shows up in the data grid. Of course when I run the app again
the new user is no longer there. I would like to know how to get
the app to update the xml file with the new information when a user
is added. A way to save the input from the form into the xml file.
If anyone can help me understand how to do this I would really be
greatful.
Thanks
GhostReading data is almost always easier that writing it. You
probably used HTTPService to load the XML data. All you needed on
the server was the XML file. The web server took care of reading
the file and packaging it to send back to the Flash Player running
the Flex application.
The reverse isn't so straightforward. The Flex part is pretty
simple however. I recommend using HTTPService with method="post" so
you can send a larger amount of data than would be possible with
method="get". If possible, to make it easy, send an entire XML
document back - all of the data. Later you can figure out how to
send just what gets updated. Baby steps are best.
The Flex HTTPService has to send the data to something on the
server which can write the XML file. Unlike reading the file and
sending it, there isn't anything (at least that I'm aware of)
ubiqutous to write the data. Your server system might already have
something you can use - so check that first. If there is nothing,
consider using PHP which is free and easy to learn. A PHP script
can accept the XML data and write it to the server's disk. -
Flex XML Parsing fails on UTF-8 encoded XML.
Flex doesn't see reliable enough for handling XML.
This basic XML file causes an error in flex. Depending on the contents of the XML, it may or may not be invalid...and its not the characters. If I put in one type of UTF8 characters, the XML is OK, if I put in another type, its also OK. If I however put in both types...then the XML fails.
So in summary, good + good = bad.
Multiple browsers, multiple versions of Flash (latest, as well as a couple prior releases), multiple OS's.
XML headers indicate the content type correctly: Content-Type: text/xml;charset=utf-8
Any suggestions?
--BenI worked around the bad XML handling in Flex by Base64 encoding my data, then Base64 decoding it in Flex. I used com.dynamicflash.util.Base64 to do the decoding.
Its a shame though...wasting extra CPU and making the flash slower just because it can't handle XML reliably.
--Ben -
Could anyone assist me on how to use the HTTPService to read
a xml file with a complex structure similar to this
<?xml version="1.0" encoding="utf-8"?>
<reports>
<report>
<reportDate>2006-11-19
<manager>
<id>0</id>
<name>Elizabeth Jones</name>
<platform>
<pltfrmName>AAA</pltfrmName>
<level>T1</level>
<desc>3G Authorization, Authentication, Accounting,
data call set up</desc>
<host>
<hostName>atlngaaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>41</cpu>
<memory>20</memory>
<cache>100</cache>
<disk>27</disk>
<network>0</network>
</host>
<host>
<hostName>atlnoraaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>38</cpu>
<memory>22</memory>
<cache>100</cache>
<disk>97</disk>
<network>0</network>
</host>
<host>
<hostName>bufcheaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>56</cpu>
<memory>23</memory>
<cache>100</cache>
<disk>96</disk>
<network>0</network>
</host>
<host>
<hostName>chrchaaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>39</cpu>
<memory>25</memory>
<cache>100</cache>
<disk>93</disk>
<network>0</network>
</host>
<host>
<hostName>indindaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>45</cpu>
<memory>22</memory>
<cache>100</cache>
<disk>96</disk>
<network>0</network>
</host>
<host>
<hostName>kcindaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>34</cpu>
<memory>25</memory>
<cache>100</cache>
<disk>78</disk>
<network>0</network>
</host>
<host>
<hostName>lanlanaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>44</cpu>
<memory>26</memory>
<cache>100</cache>
<disk>95</disk>
<network>0</network>
</host>
<host>
<hostName>nybranaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>60</cpu>
<memory>23</memory>
<cache>100</cache>
<disk>96</disk>
<network>0</network>
</host>
<host>
<hostName>sfstcaaa01</hostName>
<reportStatus>yes</reportStatus>
<cpu>45</cpu>
<memory>26</memory>
<cache>100</cache>
<disk>97</disk>
<network>0</network>
</host>
</platform>
</manager>
</reportDate>
</report>
<report>
Now, picture this for all managers in my department for the
last 30 days; I’m trying to dynamically generate
a list of array collections, and then accessing those
collections.
the collections are stored in an Object, and reference them
in an associative array that will also generate a dashboard (i.e.
like the one posted here
http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html)
per manager (node element) displaying all days. Please respond
soon. I really need your help and really admire your tutorials
posted at www.cflex.net; they’re well commented and actually
work!!
You can email me also at [email protected] for further
details.
Thanks in advance, Merry Christmas and a Happy New Year to
you and family!!!<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
viewSourceURL="src/DataProviderExternal/index.html"
width="350" height="220"
creationComplete="bs.send();"
>
<mx:Script>
<![CDATA[
import mx.managers.CursorManager;
import mx.rpc.events.InvokeEvent;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var bloggersCol:ArrayCollection;
// Gets called when HTTPService is invoked to
// request the XML.
private function bsInvokeHandler(event:InvokeEvent):void
// Display the busy cursor
CursorManager.setBusyCursor();
// Gets called when the XML is successfully loaded.
private function bsResultHandler(event:ResultEvent):void
// Save a reference to the list of bloggers
bloggersCol = event.result.bloggers.blogger;
// Hide the busy cursor
CursorManager.removeBusyCursor();
private function bsFaultHandler(event:FaultEvent):void
// There was an error in loading the XML
Alert.show (event.fault.message);
// Hide the busy cursor
CursorManager.removeBusyCursor();
]]>
</mx:Script>
<!-- Service to load in XML -->
<mx:HTTPService
id="bs"
url="data/bloggers.xml"
invoke="bsInvokeHandler(event);"
result="bsResultHandler(event);"
fault="bsFaultHandler(event);"
/>
It only loops through the base level node and children but
not the nodes under the children with children and so forth nested
within like such:
<managers>
<manager name="Elizabeth Jones" title="Capacity
Manager">
<platform desc="3G Authorization, Authentication,
Accounting, data call set up" tier="T1">AAA
<host>
<hostName>atlngaaaa01</hostName>
<currentStateReported>2006-12-18</currentStateReported>
<cpu>41</cpu>
<memory>20</memory>
<cache>100</cache>
<disk>27</disk>
<network>0</network>
</host>
<host>
</managers> -
Caching Issues with Adobe Flex and HTTPservice
I faced a strange issue a coupla days back. In one of my Applications I had a Timer which would fire every 10 secs and would fetch data using a HTTPService call when fired. Surprisingly though, the initial results fetched by the HTTPservice was cached and would not reflect any changes when the data changed in the background, in IE, however the problem would not occur in Firefox !
I sort of hacked the HTTPService url to add a random number at the end of the call to make it believe that it was calling a different URL every time and it worked. But I would definitely like to know the reason for this behaviorHi, Abesh.
I ran into the same thing, but it did not do this until recently! I had recently installed Flex 3.0 beta, so maybe something changed with the compiler and/or the Flash VM in this regard. Also, you can change the behavior of the Flex/Flash runtime by changing the caching settings in IE (check page for newer version on each visit).
Rick -
Hi
i m devlopping an HMI with flex offers to users to create
object, the user has to describe objects, (name , attribute...)
and all informations must be exported in xml file .....
so someone has a idea ????Of course you can, the only bottleneck for flex is that flex
can´t write to local disks directly (cause of the sandbox), so
you have to first create the xml file on server and than users can
download this file.
( use php for creating the xml file)
best regards
kcell -
hello,
somebody has it a piece of code allowing me in a canvas to
read a file XML and automatically to add as much field text than of
information contained in my file xml
thank you in advanceTry changing the xml structure by using CDATA instead of having the russian part as an attribute and see if that makes any difference.
What I meant is use something like this:
<?xml version="1.0" encoding="utf-8" ?>
<Autoparts>
<autopart>
<description><![CDATA[Барабан]]></description>
</autopart>
</Autoparts>
instead of the current xml. -
How to make an mp3 player with xml playlist. just like
streaming player with volume control and autoplay. Thanks and more
power.are you trying to use your xml data before loading is
complete? is there a security issue? does your player work if you
hardcode one of the mp3s? -
Adobe flex mx:httpservice
Lets say there is a error with one of the XML nodes is there a way in the faultHandler() to skip over that node and continue processing the XML data and display it
It sounds like your issue has to do with caching, check what status reports your browser when you're accessing the same data (XML file I assume) directly from browser (HttpFox is a good utility for this, on FireFox apparently).
Besides, if you generate this XML file, check if you release the locks from it (no other program is accessing it when you try to get it into SWF).
the permisions are set to minimum of 202 (read for "user" and read for "others").
the .htaccess permits accessing XML files from that location. (in case you dynamically modify it).
Also, your best way to go about such situations is to send the XML data back to the client using the server script instead of the server itself, you'll have more control over the headers you send alone with it, and less problems with permisions regulation etc. Besides, you'll be able to log any such attempt and see what you ware actually sending in response. -
Hey all,
Currently, in my rails application, I have a filtering, where the user selects an option to subset the list of data. However, these filtering options are not being outputted to xml and therefore I cannot use them in flex. Is there a solution to this? Thanks for all help.I'm not fully understanding your situation.
How are you getting the data into Flex? HTTPService? If so, the data does not have to be in XML format. It could be an array, or just a string. -
HTTPService - GET and POST in Flex
I'm sending JSON data to a PHP script on the server, and I'm a bit new to the server side stuff so I'm hoping you all can answer a few questions.
1) I thought using POST was more secure than GET, as GET sends parameters with the URL, but when I send by post, spaces are replaced with %20, so is my data really being sent by POST, or GET?
2) I thought I had heard that under certain conditions you might send data by POST, but due to a bug Flex actually sends the data by GET. What are the conditions under which this happens?
3) How can I send usernames and passwords using HTTPS in Flex using HTTPService. I assume I should use HTTPS as it is supposed to be secure.
4) I've been messing around with PHP to process the data on the server, but quite frankly, working with PHP seems really difficult. I get the data, a PHP print says its an object, but object notataion -> => does not seem to work. I've used PHP methods to get the object "keys", and also done a little with processing PHP arrays, but it still seems like PHP does not make it easy on you. Anything better for more easily transferring data securely between Flex and MySQL?
Thanks very much in advance!
GregHi Greg,
What build of Flex are you using?
1) When using HTTPS the GET URL would also be encrypted, but once decrypted on the server the URL might be logged so it's suggested to not use GET for transmitting credentials.
In 3.x, the default contentType is application/x-www-form-urlencoded - but what happens to your data depends on the type of the params passed into HTTPService.send(). Are you constructing a JSON request as a String?
BTW, did you try to set a contentType? I looked at the 3.x SDK source in SVN and the HTTPService contentType property still has metadata which provides code insight in the IDE but it also restricts the values of . When toString() is called on this XML node the root node is unwrapped and the empty string content returned. To avoid this toXMLString() can be called on the XML node to get the entire XML representation.
3) Load your SWF via HTTPS and use also HTTPS to send your credentials to the server and establish a session. If you tried to use a Basic Auth challenge you'd have to rely on the browser authentication dialog as you can no longer preauthenticate using an "Authorization" header as it is on the list of headers not allowed by flash.net.URLLoader. See the docs for URLRequestHeader used to configure headers with URLLoader:
http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html
As for how to send custom credentials... I think if you can solve your issue in 1) then the rest is up to what you want to do on the server. There should be lots of PHP login examples out there too. As a best practice try to delete / null out credentials variables when they're no longer in use on the client or server. Even though you're using HTTPS, consider additionally Base-64 encoding the credentials (for example, you could copy the format of the HTTPS Authorization header with a single "username:password" string) to obscure them in the event that a clear text version of the request is logged, or viewed in a debugger, etc.
Pete -
Using HTTPService to import data from a XML file
Hello there!
I'm having some problem's with this import... If anyone can
help, I would appreciate it!
I'm using this type of information as data source:
public var dataCollection:ArrayCollection =
new ArrayCollection([
{ id: "P1", name: "Porto", type: "team", children: [
{ id: "R1", name: "Dr Silva", location: "Bloco 1", type:
"member" },
{ id: "R2", name: "Dra Neto", location: "Gabinete", type:
"member"
{ id: "P2", name: "Braga", type: "team", children: [
{ id: "R3", name: "Dr Santos", location: "Bloco 2", type:
"member" },
{ id: "R4", name: "Dra Sonia", location: "Piso 1", type:
"member"
But I want to import it from a XML file like this:
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="P1" name="Porto" type="team">
<children id="R1" name="Dr Silva" location="Bloco 1"
type="member" />
<children id="R2" name="Dra Neto" location="Gabinete"
type="member" />
</item>
<item id="P2" name="Braga" type="team">
<children id="R3" name="Dr Santos" location="Bloco 2"
type="member" />
<children id="R4" name="Dra Sonia" location="Piso 1"
type="member" />
</item>
</items>
I already import the file, but can not translate the data
into a array collection.
private function initApp():void {
var httpService:HTTPService = new HTTPService();
httpService.url = "dataprovider.xml";
httpService.resultFormat = "e4x";
httpService.addEventListener(FaultEvent.FAULT,
onFaultHttpService);
httpService.addEventListener(ResultEvent.RESULT,
onResultHttpService);
httpService.send();
private function onFaultHttpService(e:FaultEvent):void
Alert.show("Error reading data file.");
private function onResultHttpService(e:ResultEvent):void
//Convert the xml data to a array collection
Thank youHello Peter, and thank you for your reply's.
My problem is that I'm receiving the data from the external
file and I don't know how to get the children in place... I mean, I
also have some data being received form a file that I can convert
into an array collection, but the thing is, that file doesn't have
children structure...
It's something like this:
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="T1" resourceId="R1" name="Cardiologia"
startTime="25-3-09 8:0:0" endTime="25-3-09 8:30:0" />
<item id="T2" resourceId="R2" name="Raio-X"
startTime="25-3-09 9:0:0" endTime="25-3-09 9:15:0" />
<item id="T3" resourceId="R3" name="Analises"
startTime="25-3-09 12:0:0" endTime="25-3-09 12:45:0" />
<item id="T4" resourceId="R4" name="Consulta"
startTime="26-3-09 8:0:0" endTime="26-3-09 9:0:0" />
</items>
And I solve it with this (don't know if is the best):
private function onResultHttpServiceTask(e:ResultEvent):void
var a:Array = xmlListToObjectArray(e.result.item);
tasks = new ArrayCollection(a);
protected function
xmlListToObjectArray(xmlList:XMLList):Array
var a:Array = new Array();
for each(var xml:XML in xmlList)
var attributes:XMLList = xml.attributes();
var o:Object = new Object();
for each (var attribute:XML in attributes)
var nodeName:String = attribute.name().toString();
var value:*;
value = attribute.toString();
o[nodeName] = value;
a.push(new ObjectProxy(o));
return a;
But when the children "enter in action" I don't know how to
bring them to the array...
This code you send it's preaty much the thing I need, but the
thing is that I don't know how to call the children with data as
e:ResultEvent...
If you can help a bit more, I would really appreciate...
Thank You -
HTTPService POST with XML does not declare charset encoding
Hi all.
I'm trying to do a HTTP POST of some XML using HTTPService
and I've got it working apart form the fact that the HTTP message
sent does no declare what charcater set it is using for encoding.
As a test I send a 'ñ' character and it seems from the
resultant bytes that the charset being used is UTF-8.
My ActionScript is...
var xml:XML=new XML(<root/>);
xml.@testCharacter="ñ";
xml.appendChild(<login/>);
xml.login.@username="bob";
xml.login.@password="secret";
var httpService:HTTPService=new HTTPService();
httpService.url='
http://app.localhost/null';
httpService.method="POST";
httpService.contentType=HTTPService.CONTENT_TYPE_XML;
httpService.request=xml;
httpService.send();
And what seems to get sent over the wire is (shown in
8bit-ASCII)...
POST /null HTTP/1.1
Host: app.localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png ,*/*;q=0.5
Accept-Language: en,en-us;q=0.7,en-gb;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-type: application/xml
Content-length: 77
<root testCharacter="A±">
<login username="bob" password="secret"/>
</root>
Anyone know (1) how I can control what character set gets
used for encoding and (2) how I can get either XML or HTTPService
to declare what the encoding is?
Thanks in advance, Neil.Jarod,
XML parser product managers who might be able to help you on a parser-specific issue like this "hang out" here on OTN in the XML forum. Have you tried posting there to catch their attention? Thanks.
Maybe you are looking for
-
I took 20 something pictures on the iPhone on a particular day. I created an album on the iPhone to put those specific pictures in. After getting them moved to the album, I thought I could remove them from the default location they are placed. Tha
-
How can I mix a whole show?
I am using Logic Pro. I am new to the software. I have recorded a live show. I want to mix all of the songs as the show. However, I want them to bounce into individual song files so I don't end up with one big file. I can force it by moving the
-
Partitions on external hard drive. Need advice, PLEASE!
Can someone explain to me about partitions on EHD's. I have just installed Leopard, and at present I have 3 partitions on my LaCie 250Gb Firewire external drive. I need to create enough space to allow TimeMachine to do a backup (about 120Gb). I know
-
I have published a site to the businesscatalyst.com site as I work on it. I can go to it on a computer but when I try on my tablet it has the template that I used and does not seem to update. Any ideas of why or what I can do? Thank You for any help
-
Hi , I am using tomcat on window2000 where should i put my jsp files I have copied file in work folder but it is not working