I have an ASP.NET Web service to which I pass a String of well-formed XML from AS3 as in:
<request><arg>value</arg><otherarg>value</otherarg></request>
When I compile my project using the Flex 3.4 SDK the Web service accepts my XML string and sends back the data. When I compile it using the 4.0 SDK the .NET Web service returns the following error:
System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
Any thoughts?
I was asking for you to trace() the toXMLString() just before sending to see if it is different between versions. If they are in fact the same, the next thing to do would probably be to use a network monitor to see what gets sent over the wire.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
There was a similar discussion around this problem. Please refer http://forums.adobe.com/message/1875795#1875795
Thanks,
Radhakrishna
Thanks Radhakrishna. I quickly perused your post and see a possible workaround that I might implement. Honestly though, passing the XML as a plain old string into the Web service works like a champ with SDK 3.0 and 3.4 so I'd hate to have to dig through all my code just to upgrade to 4.0.
Ok I found a decent workaround on Adobe's Bug Base ([#SDK-19811] SOAPEncoder double-encodes string values in AS proxy code generated from .NET web services. - Adobe Bug System)
Francis Potter's 3/23/09 comment was the key:
"The problem is in XMLEncoder.as, line 1784, which says: currentChild.appendChild(xmlSpecialCharsFilter(Object(value))); In Flash Player 9, it was necessary to filter for XML special characters before passing a string into appendChild, so this made sense. But for FP10 and AIR, appendChild itself escapes the strings (See Bug #1131) which is a more sensible approach but means [double-escaped] strings."
So to eliminate the double-encoding of the XML I introduced a function that does nothing except return the string (Object) that is passed to it. Then I assign that function to the xmlSpecialCharsFilter property of the WebService component.
<mx:WebService
id="webService"
wsdl="http://...asmx?WSDL"
showBusyCursor="false"
fault="apiFaultHandler(event)"
xmlSpecialCharsFilter="{ function justReturnStringUnencoded(value:Object):String { return value.toString() } }">
<mx:operation
name="GetDocumentMetadata" result="apiGetDocumentMetadataResultHandler(event)">
</mx:operation>
</mx:WebService>
This was fixed in the 3.4 release but it seems 4.0 has introduced a regression.
North America
Europe, Middle East and Africa
Asia Pacific