Share via


How to: Model a Web Method That Returns a DataSet

This sample shows how you can model a Web method that returns a DataSet with one table and three columns.

Note   Returning a DataSet from a Web method is not a good practice. The problem is that when you return a DataSet, consumers need to know the underlying structure–they cannot infer the structure from the WSDL. You also need to ensure that the internal structure of the DataSet that gets returned by the Web method does not ever change; if the internal structure changes, Business Data Catalog metadata authors might need to rewrite the application definition.

Example

<Entity Name="Customer">
   <Identifiers>
      <Identifier Name="CustomerName" TypeName="System.String" />
   </Identifiers>
   <Methods>
      <Method Name="GetCustomers">
         <Parameters>
            <Parameter Direction="In" Name="language">
               <TypeDescriptor TypeName="System.String" Name="language">
               <DefaultValues>
                  <DefaultValue MethodInstanceName="CustomerSpecificFinderInstance" Type="System.String">en-us</DefaultValue>
                  <DefaultValue MethodInstanceName="CustomerFinderInstance" Type="System.String">en-us</DefaultValue>
               </DefaultValues>
            </TypeDescriptor>
         </Parameter>
         <Parameter Direction="Return" Name="GetCustomersResult">
            <TypeDescriptor TypeName="Catalogs.ServiceDataSetContract, Catalogs" Name="GetCustomersResult">
               <TypeDescriptors>
                  <TypeDescriptor TypeName="System.Data.DataSet, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Value">
                     <TypeDescriptors>
                        <TypeDescriptor TypeName="System.Data.DataTableCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Tables" IsCollection="true">
                           <TypeDescriptors>
                              <TypeDescriptor TypeName="System.Data.DataTable, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Categories">
                                 <TypeDescriptors>
                                       <TypeDescriptor TypeName="System.Data.DataRowCollection, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Rows" IsCollection="true">
                                          <TypeDescriptors>
                                             <TypeDescriptor TypeName="System.Data.DataRow, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Categories">
<TypeDescriptors>
<TypeDescriptor TypeName="System.String" IdentifierName="CustomerName" Name="CustomerName" >
<LocalizedDisplayNames>
<LocalizedDisplayName LCID="1033">CustomerName</LocalizedDisplayName>
</LocalizedDisplayNames>
</TypeDescriptor>
<TypeDescriptor TypeName="System.String" Name="DisplayName" >
<LocalizedDisplayNames>
<LocalizedDisplayName LCID="1033">Name</LocalizedDisplayName>
</LocalizedDisplayNames>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Type="Finder" ReturnParameterName="GetCustomersResult" 
ReturnTypeDescriptorName="GetCustomersResult" 
ReturnTypeDescriptorLevel="0" Name="CustomerFinderInstance" />
<MethodInstance Type="SpecificFinder" 
ReturnParameterName="GetCustomersResult" 
ReturnTypeDescriptorName="GetCustomersResult" 
ReturnTypeDescriptorLevel="0" Name="CustomerSpecificFinderInstance" />
</MethodInstances>
</Method>
</Methods>
</Entity>