Note that there are some explanatory texts on larger screens.

plurals
  1. POMy flex code does not parse the soap response properly
    text
    copied!<p>My code is supposed to parse a SOAP response and populate the dropdown list. When I manually add the xml code it works but when I try to parse the SOAP response it runs into following error:</p> <pre><code>TypeError: Error #1009: Cannot access a property or method of a null object reference. at ex1_02_starter/dropDownList_creationCompleteHandler()[C:\Users\jack\Adobe Flash Builder 4.5\Workspace\Starter 1_02\src\ex1_02_starter.mxml:26] at ex1_02_starter/___ex1_02_starter_Operation1_result()[C:\Users\jack\Adobe Flash Builder 4.5\Workspace\Starter 1_02\src\ex1_02_starter.mxml:41] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:249] at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318] at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56] at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84] at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() </code></pre> <p>The SOAP Response that I am receiving</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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"&gt; &lt;soapenv:Body&gt; &lt;mycustomersResponse xmlns="http://Services.com"&gt; &lt;mycustomersReturn&gt; &lt;age&gt;28&lt;/age&gt; &lt;name&gt;Alex&lt;/name&gt; &lt;/mycustomersReturn&gt; &lt;mycustomersReturn&gt; &lt;age&gt;29&lt;/age&gt; &lt;name&gt;Jack&lt;/name&gt; &lt;/mycustomersReturn&gt; &lt;mycustomersReturn&gt; &lt;age&gt;30&lt;/age&gt; &lt;name&gt;Johny&lt;/name&gt; &lt;/mycustomersReturn&gt; &lt;/mycustomersResponse&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>My Flex code</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*" xmlns:hellos="services.hellos.*" height="957" creationComplete="initApp()" &gt; &lt;fx:Style source="Styles.css"/&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.XMLListCollection; import mx.events.FlexEvent; import mx.messaging.messages.SOAPMessage; import mx.rpc.events.ResultEvent; [Bindable] var _result:*; private function initApp():void { mywebservice.mycustomers(); } protected function dropDownList_creationCompleteHandler(event:ResultEvent):void { var xml:XML = event.result as XML; var xmlString:String = xml.toXMLString(); var patt:RegExp = new RegExp("xmlns[^\"]*\"[^\"]*\"", "gi"); var newXmlString:String = xmlString.replace(patt, ""); xml = new XML(newXmlString); _result = new XMLListCollection(xml.mycustomersResponse.mycustomersReturn); } ]]&gt; &lt;/fx:Script&gt; &lt;fx:Declarations&gt; &lt;s:WebService id="mywebservice" wsdl="http://localhost:8081/WebServiceTest/services/Hellos?wsdl"&gt; &lt;s:operation name="mycustomers" resultFormat="object" result="dropDownList_creationCompleteHandler(event);" /&gt; &lt;/s:WebService&gt; &lt;/fx:Declarations&gt; &lt;s:FormItem label="Label"&gt; &lt;s:DropDownList id="dropDownList" labelField="name"&gt; &lt;s:AsyncListView list="{_result}"/&gt; &lt;/s:DropDownList&gt; &lt;/s:FormItem&gt; &lt;/s:Application&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload