Expand my Community achievements bar.

Error trying to consume a ASP.NET Web Service

Avatar

Level 1

Good evevning to the community

I have a web Service thats request information from the database and display the Records in XML

example:

<ArrayOfTitleInfo>

<TitleInfo>
<strTitleName>220276</strTitleName>
<strstore_id>701       </strstore_id>
<strvoucher_id>146003</strvoucher_id>
</TitleInfo>

<TitleInfo>
<strTitleName>220276</strTitleName>
<strstore_id>702       </strstore_id>
<strvoucher_id>146016</strvoucher_id>
</TitleInfo>

<TitleInfo>
<strTitleName>220276</strTitleName>
<strstore_id>703       </strstore_id>
<strvoucher_id>146030</strvoucher_id>
</TitleInfo>

</ArrayOfTitleInfo>

I try by this Program to load the Data from The Service but it give me error


Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    backgroundGradientColors="[0xFFFFFF, 0xFFFFFF]">

        <mx:Script>
            <![CDATA[

                import mx.controls.Alert;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.soap.mxml.WebService;
                import mx.managers.CursorManager;
            

                /**
                * @bindable
                * @private
                * @property Will hold the data passed from the web service.
                */
                [Bindable]
                private var _xmlData:XML;

                /**
                * @private
                * Connects and calls the getPlayers() method from our web service.
                */
                private function clickHandler(event:MouseEvent):void
                {
                    CursorManager.setBusyCursor();
                    event.target.enabled = false;

                    var service:WebService = new WebService();
                    service.addEventListener(ResultEvent.RESULT, serviceResultHandler);
                    service.addEventListener(FaultEvent.FAULT, serviceFaultHandler);
                    service.loadWSDL("http://www.placespr.com/PLACESPR/placesService2.asmx");
                    service.GetTitleData();
                }

                /**
                * @private
                * Stores the loaded data in an XML object and displays the DataGrid.
                */
                private function serviceResultHandler(event:ResultEvent):void
                {
                    CursorManager.removeBusyCursor();
                    _xmlData = XML(event.result);
                    this.dataGrid.visible = true;
                }

                /**
                * @private
                * Displays any possible errors that might occur when
                * trying to connect to our web service.
                */
                private function serviceFaultHandler(event:FaultEvent):void
                {
                    CursorManager.removeBusyCursor();
                    Alert.show(String(event.fault), "Error");
                    this.loadBtn.enabled = true;
                }

            ]]>
        </mx:Script>

        <mx:VBox horizontalCenter="0" verticalCenter="0"
               horizontalScrollPolicy="off" verticalScrollPolicy="off">

               <mx:Button id="loadBtn" label="Load/Display Data" width="700"
                   click="clickHandler(event);"/>
               <mx:DataGrid id="dataGrid" width="100%" height="200"
                   visible="false" dataProvider="{_xmlData.*}">
                   <mx:columns>
                       <mx:DataGridColumn headerText="ID"
                           dataField="strTitleName" width="30"/>
                       <mx:DataGridColumn headerText="Name"
                           dataField="strstore_id" width="120"/>
                       <mx:DataGridColumn headerText="Score"
                           dataField="strvoucher_id" width="70"/>
                       </mx:columns>
               </mx:DataGrid>

        </mx:VBox>

</mx:Application>

Message Error Box

error_flex.gif

Thanks in Advance for any help with this problem

evick

2 Replies

Avatar

Former Community Member

What is this "input" referred to in the error message? It does not seem to be in your data, but is there a problem in one of your server side scripts with something called "input"?

Avatar

Level 1

Thanks for the Quick Response, its Strange because I have a Web Service Located here and on the output Doesn't include Nothing with the tag <input></input>

The First image of the error are from Internet Explorer, This one came from Mozilla Firefox and are a little different

flex_err.gif

Location of The Web Service

http://www.placespr.com/PLACESPR/placesService2.asmx?op=GetTitleData

And this is the code in The Web Service

Public Function GetTitleData() As TitleInfo()

        Try
            'create dataset
            Dim dsTitleData As New DataSet

            'create connection
            Dim objCon As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("dsn").ConnectionString)
            'create data adapter
            Dim cmdSQL As SqlDataAdapter = New SqlDataAdapter("SELECT emp_num, store_id, voucher_id FROM voucher", objCon)
            'fill dataset using data adapter
            cmdSQL.Fill(dsTitleData, "emp_num")

            'create object array, using row count as upper dim
            Dim objTitles As TitleInfo() = New TitleInfo(dsTitleData.Tables(0).Rows.Count - 1) {}
           

            'loop through dataset to add data to object array
            Dim intRsCount As Int16
            For intRsCount = 0 To dsTitleData.Tables(0).Rows.Count - 1
                objTitles(intRsCount) = New TitleInfo
                objTitles(intRsCount).strTitleName = dsTitleData.Tables(0).Rows(intRsCount)("emp_num")
                objTitles(intRsCount).strstore_id = dsTitleData.Tables(0).Rows(intRsCount)("store_id")
                objTitles(intRsCount).strvoucher_id = dsTitleData.Tables(0).Rows(intRsCount)("voucher_id")
                     
            Next

            'return object array
            Return objTitles

        Catch exp As Exception
            Throw
        End Try

    End Function

Thanks for the help

evick