I'm confounded by a serialization/deserialization problem we're  
running in to between CF7 CFCs and Flex. Flex is deserializing CF's  
SOAP objects just fine, but we can't get CF to read in a serialized  
object from Flex.

Here is our object:
var myObj:TestVO = new myObj:TestVO();
         myObj.deleted = false;
         myObj.title = "Test from flex";
         myObj.modified = new Date();
         myObj.externallink = "http://www.apple.com/";;
         myObj.id = 0;
         myObj.coursetype = {id:61};
         myObj.author = {id:50};

This object serializes as follows:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xmlns:xsd="http://www.w3.org/2001/XMLSchema";
     xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
     <SOAP-ENV:Body xmlns:ns1="http://remoting.interface.myapp.com";>
         <ns1:wsSet SOAP-ENV:encodingStyle="http:// 
schemas.xmlsoap.org/soap/encoding/">
             <component xsi:type="xsd:string">com.my.component.class</ 
component>
             <data xsi:type="ns2:Map" xmlns:ns2="http:// 
xml.apache.org/xml-soap">
                 <item>
                     <key xsi:type="xsd:string">author</key>
                     <value>
                         <id xsi:type="xsd:double">50</id>
                     </value>
                 </item>
                 <item>
                     <key xsi:type="xsd:string">coursetype</key>
                     <value>
                         <id xsi:type="xsd:double">61</id>
                     </value>
                 </item>
                 <item>
                     <key xsi:type="xsd:string">id</key>
                     <value xsi:type="xsd:double">0</value>
                 </item>
                 <item>
                     <key xsi:type="xsd:string">externallink</key>
                     <value xsi:type="xsd:string">http:// 
www.apple.com/</value>
                 </item>
                 <item>
                     <key xsi:type="xsd:string">title</key>
                     <value xsi:type="xsd:string">Test from flex</value>
                 </item>
                 <item>
                     <key xsi:type="xsd:string">deleted</key>
                     <value xsi:type="xsd:boolean">false</value>
                 </item>
             </data>
         </ns1:wsSet>
     </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


But the response from the CF Server gives this message (they really  
emphasize NOT!):
<faultcode>soapenv:Server.userException</faultcode>
    <faultstring>org.xml.sax.SAXException: SimpleDeserializer  
encountered a child element, which is NOT expected, in something it  
was trying to deserialize.</faultstring>
...

The CFC works with the way CF serializes data. Our CF example:
myobj = StructNew();
     StructInsert(myobj, "author", StructNew());
     StructInsert(myobj.author, "id", 50);
     StructInsert(myobj, "coursetype", StructNew());
     StructInsert(myobj.courseType, "id", 61);
     StructInsert(myobj, "id", 0);
     StructInsert(myobj, "title", "Test From CF");
     StructInsert(myobj, "externallink", "http://www.apple.com";);
     StructInsert(myobj, "deleted", false);
     swiss = CreateObject("webservice", "http:// 
remoting.interface.myapp.com");
     courseTemp = swiss.wsSet("com.my.component.class ", myobj);

This creates an envelope which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/ 
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema";  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
     <soapenv:Body>
         <ns1:wsSet soapenv:encodingStyle="http://schemas.xmlsoap.org/ 
soap/encoding/" xmlns:ns1="http://...";>
             <component xsi:type="xsd:string">com.my.component.class</ 
component>
             <data href="#id0"/>
         </ns1:wsSet>
         <multiRef id="id0" soapenc:root="0"  
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";  
xsi:type="ns2:Map" xmlns:soapenc="http://schemas.xmlsoap.org/soap/ 
encoding/" xmlns:ns2="http://xml.apache.org/xml-soap";>
             <item>
                 <key xsi:type="xsd:string">deleted</key>
                 <value xsi:type="xsd:string">false</value>
             </item>
             <item>
                 <key xsi:type="xsd:string">externallink</key>
                 <value xsi:type="xsd:string">http://www.apple.com</ 
value>
             </item>
             <item>
                 <key xsi:type="xsd:string">title</key>
                 <value xsi:type="xsd:string">Test From Flex</value>
             </item>
             <item>
                 <key xsi:type="xsd:string">coursetype</key>
                 <value href="#id1"
                     />
             </item>
             <item>
                 <key xsi:type="xsd:string">author</key>
                 <value href="#id3"/>
             </item>
             <item>
                 <key xsi:type="xsd:string">id</key>
                 <value xsi:type="xsd:string">0</value>
             </item>
         </multiRef>
         <multiRef id="id3" soapenc:root="0"  
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";  
xsi:type="ns3:Map" xmlns:ns3="http://xml.apache.org/xml-soap";  
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";>
             <item>
                 <key xsi:type="xsd:string">id</key>
                 <value xsi:type="xsd:string">50</value>
             </item>
         </multiRef>
         <multiRef id="id1" soapenc:root="0"  
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";  
xsi:type="ns4:Map" xmlns:ns4="http://xml.apache.org/xml-soap";  
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";>
             <item>
                 <key xsi:type="xsd:string">id</key>
                 <value xsi:type="xsd:string">61</value>
             </item>
         </multiRef>
         <multiRef id="id2" s
             oapenc:root="0" soapenv:encodingStyle="http:// 
schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:Map"  
xmlns:ns5="http://xml.apache.org/xml-soap"; xmlns:soapenc="http:// 
schemas.xmlsoap.org/soap/encoding/">
             <item>
                 <key xsi:type="xsd:string">id</key>
                 <value xsi:type="xsd:string">45</value>
             </item>
         </multiRef>
     </soapenv:Body>
</soapenv:Envelope>

That SOAP encoding works just fine with the CFC, but I can't seem to  
find a way to make Flex serialize objects this way. I could copy this  
envelope in to my <mx:request> tag, but that won't work with the  
'full' version of this object which has member arrays (i.e.  
myObj.subitems:Array = [1,2,3,4,n] so I'm stuck using an actual  
serializer rather than just binding to a pre-defined SOAP envelope.

I've tried the <mx:request format="xml" /> and <mx:request  
format="object" /> in my services tag, but Flex's request doesn't  
differ at all.

I've also found that sending an object such as:
var myObj:Object = new Object();
myObj.arrayTest = [{id:1},2,{name:"hi"}]

can't be deserialized by CF, returning the errorstring,  
"org.xml.sax.SAXException: No deserializer defined for array type"

This is driving me CRAZY (or maybe it is the heat). Is there a  
setting in the CFC that can be changed to make the SOAP that Flex  
delivers work? (I'm not the CF guy here, so my knowledge of that side  
of things is lacking, unfortunately)

Thanks for your help,
Sean McKibben
graphex at graphex and com



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to