Partager via


Extrait de code XML : modèle de méthodes Web polymorphes

Dernière modification : lundi 19 avril 2010

S’applique à : SharePoint Server 2010

The Service BDC (Business Data Connectivity) can support Web methods that are polymorphic. A polymorphic Web method can return different objects depending on the run-time type of the instance that invokes it. For example, suppose a Web service returns invoices, customers, orders, and related details from an accounting system. You can use a single Web method such as Object GetObject to return a customer, an invoice, order, or order detail depending on the value of the input parameter. For example, if the method is invoked with Customer as the expected return type, this Web method returns a Customer object.

When you encounter a polymorphic Web method, you must define (in the application definition file) each version of the method-return subtype that you are interested in. For the previous example, you define multiple methods, one each for Customer GetObject, Invoice GetObject, Order GetObject, and OrderDetail GetObject, depending on the values of the input parameters, BDC calls the appropriate method that matches the method signature at run time.

Exemple

<Methods>
   <Method Name="CustomerSpecificFinder">
         ….
         ….
            //The return parameter is a Customer object.
   </Method>
   <Method Name="InvoiceSpecificFinder">
         ….
         ….
            //The return parameter is an Invoice object.
   </Method>
   <Method Name="OrderSpecificFinder">
         ….
         ….
            //The return parameter is an Order object.
   </Method>
   <Method Name="OrderDetailSpecificFinder">
         ….
         ….
            //The return parameter is an Order Detail object.
   </Method>
</Methods>