Share via


How to: Model Polymorphic Web Methods

The Business Data Catalog 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(), OrderDetail GetObject() depending on the values of the input parameters, the Business Data Catalog calls the appropriate method that matches the method signature at run time.

Example

<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>