SOAP Response not unserialized correctly in Flex 4
I am seeing certain nodes of my SOAP response disappearing in Flex 4. I am using an <mx:WebService>
that is written using PHP/nusoap and 99% of the responses are unserialized correctly in Flex. For some reason this snippet is causing problems:
RAW XML:
<data xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:reportData[1]">
<item xsi:type="tns:reportData">
<name xsi:type="xsd:string">Tue. 8 Mar. 2011</name>
<year xsi:type="xsd:int">2011</year>开发者_开发问答;
<month xsi:type="xsd:int">3</month>
<day xsi:type="xsd:int">8</day>
<counts xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:double[3]">
<item xsi:type="xsd:double">26</item>
<item xsi:type="xsd:double">11</item>
<item xsi:type="xsd:double">11</item>
</counts>
</item>
</data>
The only element to show in the Flex ProxyObject is "name". All other values are simply ignored.
The WSDL defines reportData as:
<xsd:complexType name="reportData">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="url" type="xsd:string"/>
<xsd:element name="year" type="xsd:int"/>
<xsd:element name="month" type="xsd:int"/>
<xsd:element name="day" type="xsd:int"/>
<xsd:element name="hour" type="xsd:int"/>
<xsd:element name="counts" type="tns:reportCountList"/>
<xsd:element name="breakdown_total" type="tns:reportCountList"/>
<xsd:element name="breakdown" type="tns:reportDataList"/>
</xsd:all>
</xsd:complexType>
Any ideas why this XML will not unserialize correctly?
From the comments above:
According to w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all minOccurs defaults to 1 meaning it needs to be explicitly set to minOccurs=0 in the WSDL.
The above SOAP response was missing the required url
element. Changing the WSDL to explicitly define the url
element as optional minOccurs="0"
fixes the issue.
精彩评论