https://bugs.adobe.com/jira/browse/SDK-19598

Not a perfect solution, but to help out with your issue of modifying generated 
code - your generated Service stub should have a method called getWebService() 
which retuns a subclass of mx.rpc.soap.AbstractWebService. You should be able 
to set the xmlSpecialCharsFilter property on this web service instance, and 
that'll trickle down to any Operation's and then to any SOAPEncoders used by 
these Operations.

Pete


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf 
Of Francis Potter
Sent: Monday, March 23, 2009 5:20 PM
To: [email protected]
Subject: [flexcoders] Re: AIR has different behaviour in XML.appendChild() vs 
Flex for String values?


I'm glad you wrote this up because I thought I was going crazy.

In my case, I'm using the FlexBuilder-generated web services client code in 
AIR. The SOAPEncoder and XMLEncoder classes actually end up double-escaping any 
XML characters in strings that are being passed up to my web service so a 
simple "<" character becomes "&amp;lt;", which is decoded on the other end as 
"&lt;" instead of as "<".

I can see where it's happening. XMLEncoder.as, line 1784, looks like this:
                    
currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));

The "xmlSpecialCharsFilter" is doing the escaping, then appendChild (as your 
note points out) escapes the string again.

Of course, since the problem is too much escaping, pre-escaping the string 
won't help.

The only way around it in XMLEncoder is to replace the xmllSpecialCharsFilter. 
But in my case, I'm using the FlexBuilder-generated web services code (from 
Data -> Import Web Services). So for now I'm editing that code. Of course that 
means I have to re-edit the code each time my service changes and I regenerate 
it. What a pain.

Here's what I did, in Base<servicename>.call:

var enc:SOAPEncoder = new SOAPEncoder();
enc.xmlSpecialCharsFilter = function(value:Object):String {return 
value.toString()}
var soap:Object = new Object;

That works, but only in AIR (I assume, not really trying it in Flex).

So there's a hacky workaround. But really this should be fixed. At the very 
least, the FlexBuilder-generated code should be set up to work in either 
environment. As it is, "Import Web Services" will err for an AIR app where 
there is a "<" or "&" in any text property passed to the web service.

Is there a bug for this?




------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links



Reply via email to