Expand my Community achievements bar.

Parsing SOAP Results into Variables

Avatar

Level 1
Can someone assist me in figuring out what way I need to go
to parse SOAP results into an array?



I have setup the <MX:WEBService> correctly, created my
resultEvent(event) handler and faultEvenet(event) handler as
needed. Below is the web service:



<mx:WebService

id="srvGetTagHistory" wsdl="{SOAP_URL}"

result="CreateTagHistory(event)" fault="faultEvenet(event)"

useProxy="false">



<mx:operation name="GetTagHistory" resultFormat="e4x">

<mx:request>

<RSWID>{vRSWID}</RSWID>

</mx:request>

</mx:operation>

</mx:WebService>



This works perfectly. I can return the results of the
webservice to a text area control, and the complete SOAP results
are displayed.



My problem is I cannot and have not figured out how to make
the SOAP results into some type of arraycollection for using in,
lets say, a dataGrid.



Here is an example of a SOAP result for the above webservice:



<NS1:GetTagHistoryResponse
xmlns:NS1="urn:myresaleworldserviceIntf-myresaleworldserver"
xmlns:NS2="urn:myresaleworldserviceIntf" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="
http://schemas.xmlsoap.org/soap/encoding/">

<NS2:return href="#1"/>

<SOAP-ENC:Array id="1">

<item href="#2"/>

<item href="#9"/>

<item href="#16"/>

<item href="#25"/>

<item href="#29"/>

</SOAP-ENC:Array>

<NS2:rswTagHistory id="2">


<OrderDate>2005-12-08T11:15:24.857-05:00</OrderDate>

<TagType>CB Tags</TagType>

<NS2:ColorDetail href="#3"/>

</NS2:rswTagHistory>

<SOAP-ENC:Array id="3">

<item href="#4"/>

<item href="#5"/>

<item href="#6"/>

<item href="#7"/>

<item href="#8"/>

</SOAP-ENC:Array>

<NS2:rswTagColorDetail id="4">

<TagColor>Lavender</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="5">

<TagColor>Light Blue</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="6">

<TagColor>Green</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="7">

<TagColor>Pink</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="8">

<TagColor>Yellow</TagColor>

<Total>1</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagHistory id="9">


<OrderDate>2005-12-08T11:18:44.233-05:00</OrderDate>

<TagType>CB Tags</TagType>

<NS2:ColorDetail href="#10"/>

</NS2:rswTagHistory>

<SOAP-ENC:Array id="10">

<item href="#11"/>

<item href="#12"/>

<item href="#13"/>

<item href="#14"/>

<item href="#15"/>

</SOAP-ENC:Array>

<NS2:rswTagColorDetail id="11">

<TagColor>Lavender</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="12">

<TagColor>Light Blue</TagColor>

<Total>3</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="13">

<TagColor>Green</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="14">

<TagColor>Pink</TagColor>

<Total>3</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="15">

<TagColor>Yellow</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagHistory id="16">


<OrderDate>2006-08-07T13:56:22.513-05:00</OrderDate>

<TagType>CB Tags</TagType>

<NS2:ColorDetail href="#17"/>

</NS2:rswTagHistory>

<SOAP-ENC:Array id="17">

<item href="#18"/>

<item href="#19"/>

<item href="#20"/>

<item href="#21"/>

<item href="#22"/>

<item href="#23"/>

<item href="#24"/>

</SOAP-ENC:Array>

<NS2:rswTagColorDetail id="18">

<TagColor>Lavender</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="19">

<TagColor>Light Blue</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="20">

<TagColor>Green</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="21">

<TagColor>Orange</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="22">

<TagColor>Pink</TagColor>

<Total>1</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="23">

<TagColor>Red</TagColor>

<Total>2</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="24">

<TagColor>Yellow</TagColor>

<Total>1</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagHistory id="25">


<OrderDate>2007-04-10T12:08:03.950-05:00</OrderDate>

<TagType>CB Tags</TagType>

<NS2:ColorDetail href="#26"/>

</NS2:rswTagHistory>

<SOAP-ENC:Array id="26">

<item href="#27"/>

<item href="#28"/>

</SOAP-ENC:Array>

<NS2:rswTagColorDetail id="27">

<TagColor>Light Blue</TagColor>

<Total>3</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagColorDetail id="28">

<TagColor>Green</TagColor>

<Total>1</Total>

</NS2:rswTagColorDetail>

<NS2:rswTagHistory id="29">


<OrderDate>2007-12-19T12:52:30.883-05:00</OrderDate>

<TagType>Thermal Tags</TagType>

<NS2:ColorDetail href="#30"/>

</NS2:rswTagHistory>

<SOAP-ENC:Array id="30"/>

</NS1:GetTagHistoryResponse>





Any assistance to this issue would be greatly appreciated.





1 Reply

Avatar

Level 1
If you have set resultFormat="e4x" than you can handle the
result very easily.

I guess you already find out that your result is in
event.result.

Your example is too hard to parse by human.

You can read:
http://livedocs.adobe.com/labs/flex3/html/help.html?content=13_Working_with_XML_01.html

Especially: Traversing XML structures and Using XML
namespaces



I hope this will help