5 Replies Latest reply on Apr 23, 2007 6:19 PM by QuickStick

    HELP! Error on connecting to local web service

    ac361 Level 1
      I've got the following MXML file,

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="450">
      <mx:WebService id="TestApp" wsdl=" http://localhost/dir_ws/service1.asmx?WSDL" showBusyCursor="true" fault="alert(event.fault.message)">
      <mx:operation name="getSearchResults">
      </mx:operation>
      </mx:WebService>
      <mx:VBox>
      <mx:Button click="TestApp.getSearchResults.send()"></mx:Button>
      <mx:DataGrid dataProvider="{TestApp.getSearchResults.result}">
      <mx:columns>
      <mx:Array>
      <mx:DataGridColumn id="last_name" headerText="Last Name"/>
      </mx:Array>
      </mx:columns>
      </mx:DataGrid>
      </mx:VBox>
      </mx:Application>

      It's trying to read a web service on the localhost of my machine but keeps giving the error "Call to a possibly undefined method alert." on the line with the mx:webservice. I'm able to bring up the service1.asmx page successfully via Visual Studio and it gives me results. What am I doing wrong.
        • 1. Re: HELP! Error on connecting to local web service
          cialeen Level 1
          Import mx.controls.Alert;

          fault="Alert(event.fault.message)", or you can define your own alert function.

          I am not sure if this is what you want. Hope this helps.
          • 2. Re: HELP! Error on connecting to local web service
            ac361 Level 1
            As a newbie to Flex, I'm going to ask a stupid question: How do you add the import to an MXML file?
            • 3. Re: HELP! Error on connecting to local web service
              QuickStick
              Add the bold text, that should sort it out for you...

              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="450">
              <mx:Script>
              <![CDATA[
              import mx.controls.Alert;
              ]]>
              </mx:Script>

              <mx:WebService id="TestApp" wsdl=" http://localhost/dir_ws/service1.asmx?WSDL" showBusyCursor="true" fault=" Alert.show(event.fault.message)">

              Cheers.
              Oz.
              • 4. Re: HELP! Error on connecting to local web service
                ac361 Level 1
                Now it's giving a popup error saying "faultCode:DecodingError faultString: 'Error #1009' faultDetail:'null'" from the following MXML file. Also, I'm not able to use the "columnName" attribute on the DataGridColumn, even though I've imported everything I think it needs. Thanks.

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

                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="450" >
                <mx:Script>
                <![CDATA[
                import mx.controls.Alert;
                import mx.controls.DataGrid;
                import mx.controls.dataGridClasses.DataGridColumn;

                ]]>
                </mx:Script>
                <mx:WebService id="TestApp" wsdl=" http://localhost/dir_ws/service1.asmx?WSDL"
                showBusyCursor="true" fault="Alert.show(event.fault.message)">
                <mx:operation name="getSearchResults">

                </mx:operation>
                </mx:WebService>
                <mx:VBox>
                <mx:Button click="TestApp.getSearchResults.send()"></mx:Button>
                <mx:DataGrid dataProvider="{TestApp.getSearchResults.result}">
                <mx:columns>
                <mx:Array>
                <mx:DataGridColumn dataField="last_name" headerText="Last Name"/>
                </mx:Array>
                </mx:columns>
                </mx:DataGrid>
                </mx:VBox>


                </mx:Application>
                • 5. Re: HELP! Error on connecting to local web service
                  QuickStick Level 1
                  Ok, two options:

                  A. This is the example as per the WebService Docs, try adding your own variation of the bold section, to map to your own data:

                  <mx:WebService id="WS" wsdl=" http://ws.invesbot.com/stockquotes.asmx?WSDL" useProxy="true" fault="Alert.show(event.fault.faultstring), 'Error'">
                  <mx:operation name="GetQuote" resultFormat="object">
                  <mx:request>
                  <symbol>{stockSymbol.text}</symbol>
                  </mx:request>
                  </mx:operation>

                  </mx:WebService>

                  B. The WebService component also has a 'result' property. So you can try something likethis, which will hopefully get you some more information on what's wrong:

                  <mx:WebService id="TestApp" wsdl=" http://localhost/dir_ws/service1.asmx?WSDL"
                  showBusyCursor="true" fault="Alert.show(event.fault.message)" result="Alert.show(ObjectUtil.toString(event.result));">

                  And you'll need to add import mx.utils.ObjectUtil to your list of imports for this option.

                  In theory, it will give you what it got from the WebService in an Alert box, from there, see if it matches the dataProvider / Columns. I think that's where it's going wrong. What you get back doesn't suit the DataGrid.

                  Cheers
                  Oz.