Intersoft Support Center

Bind to WCF Service

This walkthrough shows you how to configure Client binding using WcfService mode in WebCombo.

During this walkthrough, you will learn how to do the following:

  • Create WcfService
  • Bind WcfService into WebCombo

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Northwind.mdf.
  • Visual Studio 2008/2010 Application.

 Step-By-Step Instructions

To configure client binding using WebService mode

  1. Launch Visual Studio.NET 2010.
  2. Click on File menu, then select New and click Web Site.
  3. Select ASP.NET Web Site in the Template box.
  4. Named the Web Site and click OK.
  5. In the Solution Explorer, right-click on App_Data and select Add Existing Item.
  6. Browse and add NorthWind.mdf in C:\Program Files\Intersoft Solutions\Data (Default installation folder).
  7. Add new page in App_Code and select Linq to Sql classes template. Named it Northwind.dbml.



  8. Drag Table Customer in Northwind.mdf from Server Explorer.


  9. Right-click on Project's name and select Add New Item.
  10. Select Intersoft AppForm in the My Templates box and named it as Walkthrough.aspx.
  11. Create WcfService.svc in the same level with your aspx name.



  12. Go to App_Code and add method GetCustomers in WcfService.cs.

    C# Copy Code
    using System.Web.Services; 
    using ISNet.ClientServices; 
    using ISNet.Data.Linq;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using ISNet.Data;
    
    [ServiceContract()]
    public class WcfService
    {
       [OperationContract]
       [ServiceKnownType(typeof(List))]
       public QueryResult GetCustomers(WcfDataSourceSelectArguments selectArguments)
       {
          NorthwindDataContext context = new NorthwindDataContext();
          context.DeferredLoadingEnabled = false;
          context.ObjectTrackingEnabled = false;
    
          WebComboDataProvider<Customer> query = 
             new WebComboDataProvider<Customer>(context.Customers);
          return query.Select(selectArguments);
       }
    }

  13. Drag WebCombo instance from Toolbox to WebForm.
  14. Set the properties based on the table and code below.

    Property Value
    BindingOperationMode ClientBinding
    DataSourceType WcfService
    ServiceUrl WcfService.asmx (or any .asmx file created by user)
    SelectMethod GetCustomers


    HTML Copy Code
    <ISWebCombo:WebCombo ID="wcSupplier" runat="server" Width="150px"
       DataTextField="ContactName" DataValueField="CustomerID" Height="20px" 
       UseDefaultStyle="True" BindingOperationMode="ClientBinding">      
       <ClientBindingSettings DataSourceType="WcfService" ServiceUrl="WcfService.svc">
          <ServiceMethods SelectMethod="GetCustomers" />
       </ClientBindingSettings>
    </ISWebCombo:WebCombo>

  15. Add the following code to web.config.

    web.config Copy Code
    <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="WcfServiceAspNetAjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <!--
            Note: The following config can be enabled when the service is running in the context of the ASP.NET HTTP application pipeline.
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
        -->
        <services>
          <service name="WcfService">
            <endpoint address="" behaviorConfiguration="WcfServiceAspNetAjaxBehavior"
             binding="webHttpBinding" contract="WcfService"/>
          </service>
        </services>
    </system.serviceModel>

  16. Save all the pages. Browse WebService.asmx to ensure that the service works then run Walkthrough.aspx.

Previous Next