• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Error 1009 when accessing webservice elements

New Here ,
Oct 25, 2012 Oct 25, 2012

Copy link to clipboard

Copied

I'm learning flex and Flash Builder 4.6 and doing a small example project.

I've created a mobile app test using a web service. I got the web service to work, creating xml dataset. I can get the flex code to access the web service and read the file. That works so far. The code reads the whole xml file from the web service and presents it. What I don't quite see is how to read only the elements. When I specify the .LastResult.element.element I get Error #1009: Cannot access a property or method of a null object reference. during runtime.

I can post the  webservice xml result if that helps. Thanks for any insights.

Here's the code

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

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

        xmlns:s="library://ns.adobe.com/flex/spark"

        xmlns:mx="library://ns.adobe.com/flex/mx"

        creationComplete="view1_creationCompleteHandler(event)"

        xmlns:service1="services.service1.*"

        xmlns:uws_lookups="services.uws_lookups.*"

        title="HomeView">

    <fx:Script>

        <![CDATA[

            import mx.rpc.soap.WebService;

            import mx.collections.ArrayCollection;

            import mx.rpc.AsyncResponder;

            import mx.collections.XMLListCollection;

            import mx.events.FlexEvent;

            import mx.rpc.events.ResultEvent;       

            import spark.events.IndexChangeEvent;

            import spark.events.TextOperationEvent;

        ]]>

    </fx:Script>

    <fx:Declarations>

        <s:WebService

            id="SampleDBwebserviceCS"

            wsdl="http://localhost:57074/Service1.asmx?WSDL"

            showBusyCursor="true" 

            useProxy= "false"

            makeObjectsBindable="true">

            <s:operation  name="Getmember" resultFormat="xml">

            </s:operation>

        </s:WebService>

        <s:CallResponder id="GetmemberResult"/>

        <service1:Service1 id="service1"/>

    </fx:Declarations>

   

    <s:VGroup width="60%" height="60%" color="#10851E" fontFamily="Arial" fontSize="10"

              fontWeight="normal" horizontalAlign="center" verticalAlign="middle">    

        <s:TextArea id="lblResult" x="2" y="0" width="188" height="234"

                    creationComplete="view1_creationCompleteHandler(event)"

                    text="{GetmemberResult.lastResult}"> 

        </s:TextArea>

        <!-- Returns the whole xml result - all fields  all xml definitions -->

        <!-- Want to return GetmemberResult.lastResult.Sales.FirstName -->

        <!-- however this causes a 1009 error on Sales-->

        <s:Button

            label="Get Data"

            click="SampleDBwebserviceCS.Getmember.send(); lblResult.text = SampleDBwebserviceCS.Getmember.lastResult"

            x="10"

            y="568">

        </s:Button>   

    </s:VGroup>

</s:View>

1009 error when I insert this property in the <s:Button   tag: 

click="SampleDBwebserviceCS.Getmember.send(); lblResult.text = SampleDBwebserviceCS.Getmember.lastResult.Sales.FirstName"

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at views::SampleSQLHomeView/___SampleSQLHomeView_Button1_click()

Views

800

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 06, 2012 Dec 06, 2012

Copy link to clipboard

Copied

LATEST

I'd have to see the xml to say what, but 1009 is what it says - a null reference has no properties, it is null.

Try tracing out SampleWebServiceCS.GetMember and you'll quickly see where along your .element.element path you have an error.

(BTW, I've not used s:Operation before, but is your syntax correct?)

G

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines