The problem seems related to the parent[name] object.
Please, see the new attached picture.
I've extended the SOAPEncoder class and overrided the getValue method. Then I set the Operation.encoder property with mine (FixedSOAPEncoder):
When it's called, parent[name].length() is 1, but the l variable is set to 0!!
And finally a workaround (for my particular case: problems invoking some SharePoint web services):
Use name.localName instead of name when name is QName.
I debugged the call to the BlazeDS server (useProxy=true) and the expected SOAP message is sent this time:
DEBUG 2012-04-17 15:43:19,688 : >> "<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <SOAP-ENV:Header>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:versions xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp">[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:version>1.0</tns:version>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:versions>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:request document="content" method="query" xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp"/>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </SOAP-ENV:Header>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <SOAP-ENV:Body>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:queryRequest xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp">[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:dsQuery resultContent="both" columnMapping="element">[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:Query RowLimit="-1">[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:Fields>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:AllFields IncludeHiddenFields="false"/>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:Fields>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <tns:Where>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <Where>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <Eq>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <FieldRef Name="ID"/>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " <Value Type="counter">1</Value>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </Eq>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </Where>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:Where>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:Query>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:dsQuery>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </tns:queryRequest>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> " </SOAP-ENV:Body>[\n]"
DEBUG 2012-04-17 15:43:19,688 : >> "</SOAP-ENV:Envelope>"
Ooopppss! There are still more issues....
All the Previous posts were related to an awesome bug: the runtime and the debugger differ about some values. Following is a more typical development bug.
The problem: previous workaround worked for elements, but not for attributes because the method:
mx.rpc.xml.XMLEncoder.encodeAttribute(definition:XML, parent:XML, name:QName, value:*=null, restriction:XML=null):void
also calls the same XMLEncoder.getValue(parent:*, name:*):* method. Thus, when parent is XML or XML list following code is used:
============================
...
var value:*;
if (parent is XML || parent is XMLList)
{
var node:XMLList = parent[name];
if (node.length() > 0)
value = node;
}
...
==============================
and no attributes are found: he resulting SOAP message ignores custom attributes and default attributes values are always added.
In this case, parent.attribute(name.localName) should be used.
I did that change (by duplicating the getValue method) and, this time, the resulting SOAP message was the the expected, including the custom attributes.
Pablo.
North America
Europe, Middle East and Africa
Asia Pacific