0 Replies Latest reply on Jan 14, 2013 8:21 PM by Emertana

    how to handle soap responses

    Emertana

      I am following this tutorial to handle SOAP responses but it does not work http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_6.html

       

      using code blew I am trying to parse the following soap response.

       

       

          <?xml version="1.0" encoding="utf-8"?>

          <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()" >

                    <fx:Style source="Styles.css"/>

                    <fx:Script>

         

                              <![CDATA[

         

                                        import mx.controls.Alert;

         

                                        private namespace invesbot = "http://Services.com";

                                        use namespace invesbot;

                                        

                                        private namespace a = "http://schemas.xmlsoap.org/soap/envelope/";

                                        private namespace b = "http://www.w3.org/2001/XMLSchema";

                                        private namespace c = "http://www.w3.org/2001/XMLSchema-instance";

                                        use namespace a;

                                        use namespace b;

                                        use namespace c;

         

                                        [Bindable]

                                        var _result:*

         

         

         

                                        private function initApp():void

                                        {

                                                  myService.mycustomers();

                                        }

         

                              ]]>

                    </fx:Script>

                    <fx:Declarations>

                              <mx:WebService id="myService" wsdl="http://localhost:8081/WebServiceTest/services/Hellos?wsdl"

                                                               showBusyCursor="true"

                                                               fault="Alert.show(event.fault.faultString), 'Error'">

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

                                                  <mx:request>

                                                  </mx:request>

                                        </mx:operation>

                              </mx:WebService>

         

                    </fx:Declarations>

          <mx:HBox>

                              <mx:Text

                                        text="{myService.mycustomers.lastResult.mycustomersReturn.name}"

                                        />

                    </mx:HBox>

          </s:Application>

       

       

       

       

      The SOAP response is as following

       

       

          <?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>

              <mycustomersResponse xmlns="http://Services.com">

                <mycustomersReturn>

                  <age>28</age>

                  <name>John</name>

                </mycustomersReturn>

                <mycustomersReturn>

                  <age>29</age>

                  <name>Alex</name>

                </mycustomersReturn>

                <mycustomersReturn>

                  <age>30</age>

                  <name>Jack</name>

                </mycustomersReturn>

              </mycustomersResponse>

            </soapenv:Body>

          </soapenv:Envelope>

       

       

      Using the above code the output will be

       

       

          <name xmlns="http://Services.com" 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">John</name>

          <name xmlns="http://Services.com" 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">Alex</name>

          <name xmlns="http://Services.com" 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">Jack</name>

       

       

      but when I use the following code to put the result in dropdown box it gives the following error

       

       

       

       

       

          <s:FormItem label="Employee:">

                              <s:DropDownList id="dropDownList3"

                                                                      labelField="name"

                                                                      dataProvider ="{myService.mycustomers.lastResult.mycustomersReturn}"/>

                    </s:FormItem>

       

       

       

       

      TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@106e9af1 to mx.collections.IList.