Compartilhar via


XML Snippet: Model of a Web Method That Returns a DataSet

Applies to: SharePoint Server 2010

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

Note

Returning a DataSet object from a Web method is not a best practice. The problem is that when you return a DataSet object, consumers must know the underlying structure; they cannot infer the structure from the WSDL. You also need to ensure that the internal structure of the DataSet object that gets returned by the Web method does not ever change; if the internal structure changes, you 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>