8 Replies Latest reply on Jul 5, 2007 11:14 AM by ntsiii

    XMLList Problem

    Thenmalar
      Hi Nitsii,
      I'm new to flex.Can anyone please guide me .
      I used webservices for accessing SAP Backend. i get the result as XML format.
      xmlresult=XML(event.result); & store the values of the particular field to xml List. If i choose the Qualification text from Combo control corresponding ID of the QualificationText field sholud be retrieved from Qualification table.how do i do that.??
        • 1. Re: XMLList Problem
          gjastrab Level 1
          Please give an example of the XML you're getting back and what part you're trying to pull out. This is too vague to answer so far.
          • 2. Re: XMLList Problem
            Thenmalar Level 1
            I have sent u my MXML file to u.
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="1500" height="1600" x="6" y="103" creationComplete="doNewSearch()">

            <mx:Script>
            <![CDATA[
            import mx.rpc.AbstractService;

            import mx.rpc.soap.mxml.WebService;
            import mx.events.ItemClickEvent;
            import mx.rpc.events.ResultEvent;
            import mx.managers.CursorManager;
            import mx.controls.Alert;
            import mx.collections.*;
            import mx.utils.ArrayUtil;

            default xml namespace = " http://entegdt21.enteg.com";
            [Bindable]public var _xmlResult:XML; //holds the result xml
            [Bindable]public var _xmlResult2:XML;
            [Bindable]public var _xlDataSpecial:XMLList; //dataProvider for the day weather dataGrid
            [Bindable]public var _xlDataSpecialID:XMLList;
            [Bindable]public var _xlDataQualifID:XMLList;
            [Bindable]public var _xlDataQualif:XMLList;
            [Bindable]public var _xlDataSkill:XMLList;
            [Bindable]public var _xlDataSkillID:XMLList;
            [Bindable]public var _xlDataProfi:XMLList;
            [Bindable]public var _xlDataProfiID:XMLList;
            [Bindable]public var _xlDataAdv: XMLList;
            [Bindable]public var _xlDataAdvID:XMLList;
            [Bindable]public var _xlDataDesig :XMLList;
            [Bindable]public var _xlDataDesigID :XMLList;

            [Bindable]public var _xlDataPostn :XMLList;
            [Bindable]public var _xlDataPostnID :XMLList;
            [Bindable]public var _xlDataIndustry:XMLList;
            [Bindable]public var _xlDataIndustryID :XMLList;
            [Bindable]public var _sAppno:String;
            [Bindable]
            public var stateArray:ArrayCollection=new ArrayCollection();
            public var obj:Object="SELECT";
            // [Bindable]

            public function doNewSearch():void {
            CursorManager.setBusyCursor();
            WES2.ZhrFunApplicantMasterdata.send();
            }

            public function onResult(oEvent:ResultEvent):void
            {

            _xmlResult = XML(oEvent.result);
            // stateArray = oEvent.result as ArrayCollection;
            //stateArray=_xmlResult.TSpeciallisation.item.Atext as ArrayCollection;

            _xlDataSpecial =_xmlResult.TSpeciallisation.item.Atext;
            _xlDataSpecialID=_xmlResult.TSpeciallisation.item.Ausbi;

            // _xlDataSpecialID=_xmlResult.TProficency.item.ScaleId;
            _xlDataQualif=_xmlResult.TQualification.item.Stext;
            _xlDataQualifID=_xmlResult.TQualification.item.Slart;

            _xlDataSkill=_xmlResult.TSkill.item.Zqtest;
            _xlDataSkillID=_xmlResult.TSkill.item.Zsobid;


            _xlDataProfi=_xmlResult.TProficency.item.Pstext;
            _xlDataProfiID=_xmlResult.TProficency.item.Rating;
            _sAppno= _xlDataProfi[0].toString();


            _xlDataIndustry=_xmlResult.TIndustry.item.Brtxt;
            _xlDataIndustryID=_xmlResult.TIndustry.item.Brsch;

            _xlDataDesig=_xmlResult.TDesignation.item.Ltext;
            _xlDataDesigID=_xmlResult.TDesignation.item.Taete;

            _xlDataPostn=_xmlResult.TPosition.item.Plstx;
            _xlDataPostnID=_xmlResult.TPosition.item.Plans;

            _xlDataAdv =_xmlResult.TAdvertisement.item.Iname;
            _xlDataAdvID=_xmlResult.TAdvertisement.item.Rcins;

            // Alert.show("value:"+ _xlDataProfiID.toString());
            Alert.show("value:"+ _xlDataSpecialID.toString());
            CursorManager.removeBusyCursor();



            } //onResult


            public function changeProfi(event:Event):void
            {
            // Alert.show("appno:"+ _sAppno);
            for(var i:Number=0;i<=_xlDataProfi.length();i++)
            {
            //Alert.show("len:"+ _xlDataProfi.length());
            if((_xlDataProfi .toString())==event.currentTarget.selectedItem)
            {
            var Profino:Number=_xlDataProfiID
            ;
            Alert.show("profino:"+Profino);
            }
            // outputInfo.text+=event.currentTarget.selectedItem+ " " +
            // event.currentTarget.selectedIndex + "\n";
            }

            }


            public function changeSpecial(event:Event):void
            {
            ...........
            }

            public function changeQualif(event:Event):void
            {
            ..............
            }

            public function changeSkill(event:Event):void
            {

            ................................
            }


            public function changeIndustry(event:Event):void
            {
            ........................
            }
            public function changeDesig(event:Event):void
            {

            .....................
            }


            public function changePosition(event:Event):void
            { ...............................

            }

            public function changeAdv(event:Event):void
            {

            .................................
            }

            • 3. Re: XMLList Problem
              Thenmalar Level 1
              public function submitfun():void
              {
              // Alert.show("Print:"+firstname0.text); text="{WES3.ZhrFunApplicantCreate.lastResult.ApplicantNumber}"
              CursorManager.setBusyCursor();
              WES3.ZhrFunApplicantCreate.send();
              }



              public function onResult2(Event2:ResultEvent):void
              {

              Alert.show("Result value1:");
              _xmlResult2 = XML(Event2.result);

              outputInfo.text = _xmlResult2.toXMLString();
              Alert.show("Result value1:");
              // Alert.show("Result"+( _xmlResult.EX_EMPLOYID.text()).toXMLString());

              var xmlResultNode:XML = _xmlResult2.Applicantnumber[0];
              // var xmlDetailsNode:XML = xmlResultNode.Details[0];
              // output1.text = _xmlResult.toXMLString();
              _sAppno = xmlResultNode.text();
              Alert.show("Result value:"+_sAppno.toString());
              CursorManager.removeBusyCursor();
              } //onResult


              public function cleardata():void
              {
              ......................... }



              ]]>

              </mx:Script>


              <mx:WebService id="WES2" destination="masterws" useProxy="true" fault="Alert.show(event.fault.faultString) , 'Error'" result="onResult(event)" >
              <mx:operation name="ZhrFunApplicantMasterdata" resultFormat="e4x" >
              <mx:request>
              <TAdvertisement>

              </TAdvertisement>
              <TDesignation>
              </TDesignation>
              <TIndustry>
              </TIndustry>
              <TPosition>
              </TPosition>
              <TProficency>
              </TProficency>
              <TQualification>
              </TQualification>
              <TSkill>
              </TSkill>
              <TSpeciallisation>
              </TSpeciallisation>
              </mx:request>
              </mx:operation>

              </mx:WebService>

              <mx:WebService id="WES3" destination="applicantws" useProxy="true" fault="Alert.show(event.fault.faultString) , 'Error'" result="onResult2(event)" >
              <mx:operation name="ZhrFunApplicantCreate" resultFormat="e4x" >
              <mx:request>
              <Address1>
              {address0.text}
              </Address1>
              <Address2>
              {address3.text}
              </Address2>
              <Advert>
              {int(Adv.text)}
              </Advert>
              <BDate>
              <!-- {(DOB0.text) as Date} -->
              </BDate>
              <City>
              {city0.text}
              </City>
              <Cntry>
              </Cntry>
              <EMail>
              {emailid0.text}
              </EMail>
              <Education>

              </Education>
              <ExpStatus>
              </ExpStatus>
              <FName>
              {firstname0.text}
              </FName>
              <Gender>
              {gender0.text}
              </Gender>
              <LName>
              {lastname0.text}
              </LName>
              <PcdCity>
              {int(postalcode0.text)}
              </PcdCity>
              <PreviousEmployment>

              </PreviousEmployment>
              <Qualification>

              </Qualification>
              <SText>
              {outputInfo.text}
              </SText>
              <TelNo>
              {int(phno0.text)}
              </TelNo>
              <VacancyAssignment>

              </VacancyAssignment>
              </mx:request>
              </mx:operation>

              </mx:WebService>


              <mx:Panel x="114" y="0" width="1138" height="1600" layout="absolute" autoLayout="true" backgroundColor="#FFFFFF">
              <mx:TextInput id="Adv" text="00000001"
              width="175" x="118"/>
              <mx:TextInput id="Result" text="{WES3.ZhrFunApplicantCreate.lastResult.ApplicantNumber}"

              width="268" x="425" y="0"/>
              <mx:HBox x="55" y="197" width="100%" height="42">
              <mx:Label text="Position Applied For:" width="123"/>
              <mx:ComboBox dataProvider="{_xlDataPostn}" change="changePosition(event)" width="118"></mx:ComboBox>
              <mx:Label text="Advertisement:"/>
              <mx:ComboBox dataProvider="{_xlDataAdv}" change="changeAdv(event)" width="118"></mx:ComboBox>
              </mx:HBox>
              ...................

              <mx:ComboBox
              dataProvider="{_xlDataSpecial}"
              selectedItem="Translator" change="changeSpecial(event)"
              width="135">
              </mx:ComboBox>
              <mx:VRule height="31" width="3"/>
              <mx:TextInput width="276"/>
              <mx:VRule height="31" width="3"/>
              <mx:VRule height="26" width="0"/>
              <mx:TextInput width="84"/>
              <mx:VRule height="31" width="4"/>
              <mx:DateField width="138"/>
              <mx:VRule height="31" width="3"/>
              <mx:DateField width="126"/>
              </mx:HBox>
              <mx:HBox width="981" height="28">
              <mx:ComboBox dataProvider="{_xlDataQualif}" width="112"></mx:ComboBox>
              <mx:VRule height="31" width="3"/>
              <mx:ComboBox dataProvider="{_xlDataSpecial}" width="135"></mx:ComboBox>
              <mx:VRule height="31" width="3"/>
              <mx:TextInput width="276"/>
              <mx:VRule height="31" width="3"/>
              <mx:VRule height="26" width="0"/>
              <mx:TextInput width="84"/>
              <mx:VRule height="31" width="4"/>
              <mx:DateField width="138"/>
              <mx:VRule height="31" width="3"/>
              <mx:DateField width="126"/>
              </mx:HBox>
              </mx:VBox>

              ................................


              <mx:VBox x="55" y="1091" height="269" width="776">
              <mx:Text text="Resume:" width="180" fontSize="13"/>
              <mx:TextArea height="236" width="719" id="outputInfo"/>
              </mx:VBox>
              <mx:HBox x="370.5" y="1426" width="133" height="32">
              <mx:Button label="SAVE" click="submitfun()"/>
              <mx:Button label="RESET" click="cleardata()"/>

              ...........................



              <mx:HBox x="55" y="305" width="869" height="253">
              <mx:Form width="333" height="222">
              <mx:FormItem label="Firstname">
              <mx:TextInput id="firstname0"
              width="169"/>
              </mx:FormItem>
              <mx:FormItem label="Lastname">
              <mx:TextInput id="lastname0"
              width="169"/>
              </mx:FormItem>
              <mx:FormItem label="Gender">
              <mx:TextInput id="gender0"
              width="127"/>
              </mx:FormItem>
              <mx:FormItem label="Address1">
              <mx:TextInput id="address0"
              width="216"/>
              </mx:FormItem>
              <mx:FormItem label="Address2">
              <mx:TextInput id="address3"
              width="217"/>
              </mx:FormItem>
              </mx:Form>
              <mx:Form height="220" width="455">
              <mx:FormItem label="City">
              <mx:TextInput id="city0"
              width="176"/>
              </mx:FormItem>
              <mx:FormItem label="Postal Code">
              <mx:TextInput id="postalcode0"
              width="174"/>
              </mx:FormItem>
              <mx:FormItem label="Date Of Birth">
              <mx:TextInput id="DOB0"
              width="174"/>
              </mx:FormItem>
              <mx:FormItem label="EmailId">
              <mx:TextInput id="emailid0"
              width="174"/>
              </mx:FormItem>
              <mx:FormItem label="Phone No">
              <mx:TextInput id="phno0"
              width="175"/>
              </mx:FormItem>
              </mx:Form>
              </mx:HBox>
              <mx:Label x="320" y="2" text="Result:" width="70"/>
              </mx:Panel>


              </mx:Application>


              onResult2() funtion is not been called.........
              i don't know y?????


              thanks
              regards,
              Then malar
              • 4. Re: XMLList Problem
                ntsiii Level 3
                It should be. Try putting the result handler specification on the operation instead of on the main Webservice tag.

                Are you suer send() is being called? There is no fault?

                Tracy
                • 5. Re: XMLList Problem
                  ntsiii Level 3
                  Also, using declaritive binding to build the Request object is hard to debug.

                  Do it in as, so you can be sure you have good values. the malformed xml error in your other post could occur if on of your bound values is null or undefined.

                  Tracy
                  • 6. Re: XMLList Problem
                    Thenmalar Level 1
                    HI,
                    Thanks 4 ur Solution Nitsii.. i try that.I don't know how to pass the set of different Data types as a Node to a webservice through XML format... can u plz guide me.. & regarding the XML error ,The values are getting updated at the Backend. it gives me the error while processing the Result. I am using SAP as the Backend. so in SAP the Applicant Number(Result) is generated Properly.
                    but i couldn't get the result in my Flex....could u plz find me the solution for my queries???
                    thank u.

                    Regards,
                    Thenmalar
                    • 7. Re: XMLList Problem
                      Thenmalar Level 1
                      Hi ntsiii,
                      I just want to simplyfy my Qurey, that is how to pass Complex structures to Webservice.Actually i tried with Action Script
                      Class Employee{
                      Public Var FirstName: String;
                      Public Var LastName: String;
                      Public Var salary: Number;
                      }

                      In my Mxml file,
                      i have imported the Action Script class & create an object
                      Employee emp=new Employee();
                      emp.firstName=text1.text;
                      ................


                      but in my Action Script file i need to call one more complex structure Education which contains some 4 different data types
                      I don't know how to do that .......
                      Is this the Procedure to access Complex structure???
                      Could u please help me



                      • 8. Re: XMLList Problem
                        ntsiii Level 3
                        I am not familiar enough with web services to know how to pass complex objects, sorry. Maybe there are some examples in the SAP documentation.

                        But if SAP is getting the data correctly as is, just leave it as is.

                        One debug option is to change the resultFormat of your data service call to "text". This way you can get the string, and paste it into an xml debugger.

                        Tracy