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

web service method binding (flash builder issue)

Guest
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

I have a new Flash Builder (Flex) project, basically it has 2 combo boxes in it. I have added a web service, the service is called uws_lookups and has 2 methods, lookupLanguage and lookupCountry.

If I bind a combobox to the result from either of these services everything works as expected, here is the code:

<?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:uws_lookups="services.uws_lookups.*"
      minWidth="955" minHeight="600">
<fx:Script>
  <![CDATA[
   import com.adobe.serializers.utility.TypeUtility;

   import mx.controls.Alert;
   import mx.events.FlexEvent;

   protected function comboBox_creationCompleteHandler(event:FlexEvent):void
   {
    lookupCountryResult.token = uws_lookups.lookupCountry();
   }

  ]]>
</fx:Script>
<fx:Declarations>
  <s:CallResponder id="lookupCountryResult"/>
  <uws_lookups:Uws_lookups id="uws_lookups"
         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
         showBusyCursor="true"/>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)" labelField="countryName">
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
</s:ComboBox>
<s:ComboBox/>
</s:Application>

As you can see the combobox gets bound, the results are returned and displayed, however when I bind the second box to the other method Flash Builder does the most stupid thing ever:

<?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:uws_lookups="services.uws_lookups.*"
      minWidth="955" minHeight="600">
<fx:Script>
  <![CDATA[
   import com.adobe.serializers.utility.TypeUtility;
  
   import mx.controls.Alert;
   import mx.events.FlexEvent;
  
   protected function comboBox_creationCompleteHandler(event:FlexEvent):void
   {
    lookupCountryResult.token = uws_lookups.lookupCountry();
   }

  
   protected function comboBox2_creationCompleteHandler(event:FlexEvent):void
   {
    lookupLanguageResult.token = uws_lookups.lookupLanguage();
   }
  
  ]]>
</fx:Script>
<fx:Declarations>
  <s:CallResponder id="lookupCountryResult"/>

  <s:CallResponder id="lookupLanguageResult"/>


  <uws_lookups:Uws_lookups id="uws_lookups" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>

  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>


<s:ComboBox id="comboBox" creationComplete="comboBox_creationCompleteHandler(event)" labelField="countryName">
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
</s:ComboBox>


<s:ComboBox id="comboBox2" creationComplete="comboBox2_creationCompleteHandler(event)" labelField="LanguageName">
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Country.Rows)}"/>
</s:ComboBox>


</s:Application>

Now I'm pretty sure that isnt what I asked it to do, so I manually change the code line to read correctly

  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Language.Rows)}"/>

Which enables to second combobox to work, but the original one (countries) now displays [Object: Language_type]

I have debugged the application and both methods do actually return the correct data, FB is just choosing to do something stupid when I add the second call.

I have done the basics, deleted the project and started again, tried a different web service, tried different methods, but it looks like when I use more than one method it fails, so please tell me, what am I doing wrong because I know Flash Builder cannot be doing this by design.

I will post the service response in another post.

Thanks for any help you have!

Shaine

Views

2.0K

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

correct answers 1 Correct answer

Deleted User
Jan 09, 2012 Jan 09, 2012

It appears that the clue was in the code you couldnt see. When you auto detect return type all of the lookup* methods return as tables.table.<lookup_name>_type.value, so when I add the second lookup method to the second component for some reason Flash Builder mashes the code in Tables.as, Table.as and the _super_*.as classes.

Renaming the Tables and Table returns resolves the issue and it works exactly as designed.

I know I will regret this in a minute, but puting that in the help files, hints or

...

Votes

Translate

Translate
Guest
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

The webmethod response COUNTRY:

<NewDataSet xmlns="">

      <Country diffgr:id="Country1" msdata:rowOrder="0">

        <ID>479</ID>

        <countryName>Afghanistanco</countryName>

      </Country>

      <Country diffgr:id="Country2" msdata:rowOrder="1">

        <ID>480</ID>

        <countryName>Albania</countryName>

      </Country>

      <Country diffgr:id="Country3" msdata:rowOrder="2">

        <ID>481</ID>

        <countryName>Algeria</countryName>

      </Country>

</NewDataSet>

and LANGUAGE:

<NewDataSet xmlns="">

      <Language diffgr:id="Language1" msdata:rowOrder="0">

        <ID>1</ID>

        <LanguageName>Abkhazian</LanguageName>

        <LanguageCode>ab</LanguageCode>

      </Language>

      <Language diffgr:id="Language2" msdata:rowOrder="1">

        <ID>2</ID>

        <LanguageName>Afar</LanguageName>

        <LanguageCode>aa</LanguageCode>

      </Language>

      <Language diffgr:id="Language3" msdata:rowOrder="2">

        <ID>3</ID>

        <LanguageName>Afrikaans</LanguageName>

        <LanguageCode>af</LanguageCode>

      </Language>

</NewDataSet>

Thanks again.

Shaine

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
Guest
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

OK, here are the returns from the 2 web service calls, firstly Country (abbreviated)

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

<DataSet xmlns="http://microsoft.com/webservices/">

  <xs:schema id="Countries" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

    <xs:element name="Countries" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">

      <xs:complexType>

        <xs:choice minOccurs="0" maxOccurs="unbounded">

          <xs:element name="Country">

            <xs:complexType>

              <xs:sequence>

                <xs:element name="ID" type="xs:int" minOccurs="0" />

                <xs:element name="countryName" type="xs:string" minOccurs="0" />

              </xs:sequence>

            </xs:complexType>

          </xs:element>

        </xs:choice>

      </xs:complexType>

    </xs:element>

  </xs:schema>

  <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

    <Countries xmlns="">

      <Country diffgr:id="Country1" msdata:rowOrder="0">

        <ID>479</ID>

        <countryName>Afghanistanco</countryName>

      </Country>

      <Country diffgr:id="Country2" msdata:rowOrder="1">

        <ID>480</ID>

        <countryName>Albania</countryName>

      </Country>

      <Country diffgr:id="Country3" msdata:rowOrder="2">

        <ID>481</ID>

        <countryName>Algeria</countryName>

      </Country>

    </Countries>

  </diffgr:diffgram>

</DataSet>

And then the Language output:

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

<DataSet xmlns="http://microsoft.com/webservices/">

  <xs:schema id="Languages" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

    <xs:element name="Languages" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">

      <xs:complexType>

        <xs:choice minOccurs="0" maxOccurs="unbounded">

          <xs:element name="Language">

            <xs:complexType>

              <xs:sequence>

                <xs:element name="ID" type="xs:int" minOccurs="0" />

                <xs:element name="LanguageName" type="xs:string" minOccurs="0" />

                <xs:element name="LanguageCode" type="xs:string" minOccurs="0" />

              </xs:sequence>

            </xs:complexType>

          </xs:element>

        </xs:choice>

      </xs:complexType>

    </xs:element>

  </xs:schema>

  <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

    <Languages xmlns="">

      <Language diffgr:id="Language1" msdata:rowOrder="0">

        <ID>1</ID>

        <LanguageName>Abkhazian</LanguageName>

        <LanguageCode>ab</LanguageCode>

      </Language>

      <Language diffgr:id="Language2" msdata:rowOrder="1">

        <ID>2</ID>

        <LanguageName>Afar</LanguageName>

        <LanguageCode>aa</LanguageCode>

      </Language>

      <Language diffgr:id="Language3" msdata:rowOrder="2">

        <ID>3</ID>

        <LanguageName>Afrikaans</LanguageName>

        <LanguageCode>af</LanguageCode>

      </Language>

    </Languages>

  </diffgr:diffgram>

</DataSet>

No errors occur, but as noted above, when I add the webservices they load fine, the issue occurs when I bind them to components, because I have to autodetect the return type, which appears to be causing the problem.

Now I am not aware of any issues with any of my strongly typed data sets, and oter web services seem to work fine, so the question is, why is Flash Builder reacting this way to these specific set of web services, and the only information I have got is that they are all methods of the same service, and these are the only ones that are not strongly typed. But really I could do with the assistance because there are nearly 200 of these used throughout the application so any insight might just stop me dropping FB altogether.

If it makes any diference at all, we are using the SDK 4.5.1, with Flash Builder 4.5 Premium.

Thanks

Shaine

Message was edited by: ProcessEndNow

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
Guest
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

Issue 1:

_Super_LookupCountryResult.as contains the following wrong line, which only appears after I add the lookupLanguage resulttype!

model_internal static function initRemoteClassAliasAllRelated() : void
    {
        valueObjects.Tables.initRemoteClassAliasSingleChild();
        valueObjects.Table.initRemoteClassAliasSingleChild();
        valueObjects.Language_type.initRemoteClassAliasSingleChild();
    }

The file _Super_Table.as contains many references to Language_type but none to Country_type, whereas _Super_Tables.as references both.

In short, it doesnt appear to be a user error, it appears to be Flash Builder not realising that there are 2 webmethods, and/or failing to update the valueObjects correctly, and as they outnumber me, I think I am stuffed, all ideas now welcome, apart from add/remove programs

Shaine

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
Guest
Jan 07, 2012 Jan 07, 2012

Copy link to clipboard

Copied

Ok, lets prove I'm not going mad. New Project, add webservice, which has 2 methods as before. Drag datagrid to stage and bind to data for lookup countries, the code generated is:

<?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:uws_lookups="services.uws_lookups.*"
      minWidth="955" minHeight="600">
<fx:Script>
  <![CDATA[
   import com.adobe.serializers.utility.TypeUtility;
  
   import mx.controls.Alert;
   import mx.events.FlexEvent;
  
   protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
   {
    lookupCountryResult.token = uws_lookups.lookupCountry();
   }

  ]]>
</fx:Script>
<fx:Declarations>
  <s:CallResponder id="lookupCountryResult"/>
  <uws_lookups:Uws_lookups id="uws_lookups"
         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
         showBusyCursor="true"/>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
    creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
    <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
  <s:typicalItem>
   <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
  </s:typicalItem>
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
</s:DataGrid>
</s:Application>

So. now te good bit, drag another datagrid to the stage and bind to the second method (languages), and guess what? it all goes horribly wrong, here is the complete code for that too:

<?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:uws_lookups="services.uws_lookups.*"
      minWidth="955" minHeight="600">
<fx:Script>
  <![CDATA[
   import com.adobe.serializers.utility.TypeUtility;
  
   import mx.controls.Alert;
   import mx.events.FlexEvent;
  
   protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
   {
    lookupCountryResult.token = uws_lookups.lookupCountry();
   }

  
   protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
   {
    lookupLanguageResult.token = uws_lookups.lookupLanguage();
   }
  
  ]]>
</fx:Script>
<fx:Declarations>
  <s:CallResponder id="lookupCountryResult"/>
  <uws_lookups:Uws_lookups id="uws_lookups"
         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
         showBusyCursor="true"/>
  <s:CallResponder id="lookupLanguageResult"/>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
    creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
    <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
  <s:typicalItem>
   <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
  </s:typicalItem>
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
</s:DataGrid>
<s:DataGrid id="dataGrid2" x="418" y="10" width="400" height="590"
    creationComplete="dataGrid2_creationCompleteHandler(event)" requestedRowCount="4">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
    <s:GridColumn dataField="LanguageName" headerText="LanguageName"></s:GridColumn>
    <s:GridColumn dataField="LanguageCode" headerText="LanguageCode"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
  <s:typicalItem>
   <fx:Object ID="ID1" LanguageCode="LanguageCode1" LanguageName="LanguageName1"></fx:Object>
  </s:typicalItem>
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Country.Rows)}"/>
</s:DataGrid>
</s:Application>

Now this is without ANY modification from me whatsoever, and all I get is the CountryID field displayed, so I modify the code manually to read:

<?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:uws_lookups="services.uws_lookups.*"
      minWidth="955" minHeight="600">
<fx:Script>
  <![CDATA[
   import com.adobe.serializers.utility.TypeUtility;
  
   import mx.controls.Alert;
   import mx.events.FlexEvent;
  
   protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
   {
    lookupCountryResult.token = uws_lookups.lookupCountry();
   }

  
   protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
   {
    lookupLanguageResult.token = uws_lookups.lookupLanguage();
   }
  
  ]]>
</fx:Script>
<fx:Declarations>
  <s:CallResponder id="lookupCountryResult"/>
  <uws_lookups:Uws_lookups id="uws_lookups"
         fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
         showBusyCursor="true"/>
  <s:CallResponder id="lookupLanguageResult"/>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:DataGrid id="dataGrid" x="10" y="10" width="400" height="580"
    creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
    <s:GridColumn dataField="countryName" headerText="countryName"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
  <s:typicalItem>
   <fx:Object countryName="countryName1" ID="ID1"></fx:Object>
  </s:typicalItem>
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupCountryResult.lastResult.Tables.Country.Rows)}"/>
</s:DataGrid>
<s:DataGrid id="dataGrid2" x="418" y="10" width="400" height="590"
    creationComplete="dataGrid2_creationCompleteHandler(event)" requestedRowCount="4">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="ID" headerText="ID"></s:GridColumn>
    <s:GridColumn dataField="LanguageName" headerText="LanguageName"></s:GridColumn>
    <s:GridColumn dataField="LanguageCode" headerText="LanguageCode"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
  <s:typicalItem>
   <fx:Object ID="ID1" LanguageCode="LanguageCode1" LanguageName="LanguageName1"></fx:Object>
  </s:typicalItem>
  <s:AsyncListView list="{TypeUtility.convertToCollection(lookupLanguageResult.lastResult.Tables.Language.Rows)}"/>
</s:DataGrid>
</s:Application>

And now I can see the CountryID, LanguageID, LanguageName and LanguageCode, but still no Country Name, so where do I look now, and more to the point why is this happening?

Please please please please help, this is just slightly more than business critical, I have to justify the cost of this project, and so far, not having  lot of fun with it.

Thanks

Shaine

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
Guest
Jan 08, 2012 Jan 08, 2012

Copy link to clipboard

Copied

I am hoping that someone has the MOnday morning flash of inspiration required to help me solve this, the situation is no better. I was going to upgrade to Flash Builder 4.6 but I get that lovely generic 'A Prerelease version of this software is already installed' which I assume means that 4.5 is stopping it being installed. So today is going to be a VERY long day!

All help appreciated,

Shaine

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
Guest
Jan 09, 2012 Jan 09, 2012

Copy link to clipboard

Copied

So, my plan for Monday inspiration seemed to fail

So, in summary, for reasons that cannot be explained, if you have a web service with multiple methods, and you want to bind a control to each method, you can't?

For a data-centric application this seems a little odd, and I can bind each method individually to a control so the web-services are fine, so that leaves Flash Builder as the weak link!

Well if that doesn't make you smile, nothing will.

I will leave this post open, just in case the coffee hasnt kicked in yet

Thanks for all your inout so far.

Shaine

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
Guest
Jan 09, 2012 Jan 09, 2012

Copy link to clipboard

Copied

Fo the record, Flash Builder 4.6 also fails in exactly the same way, installed it onto a new laptop this morning and did exactly the same procedure.

Shaine

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
Guest
Jan 09, 2012 Jan 09, 2012

Copy link to clipboard

Copied

LATEST

It appears that the clue was in the code you couldnt see. When you auto detect return type all of the lookup* methods return as tables.table.<lookup_name>_type.value, so when I add the second lookup method to the second component for some reason Flash Builder mashes the code in Tables.as, Table.as and the _super_*.as classes.

Renaming the Tables and Table returns resolves the issue and it works exactly as designed.

I know I will regret this in a minute, but puting that in the help files, hints or on the KB would have been a *really* useful thing to do Adobe, I love your products, I love the samples and the demos, but your doco sucks (sorry but it does).

Apologies for ranting, issue resolved, gie myself some points.

Regards

Shaine

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