Edit this page

Sending Additional Information to the Web Service

In our examples, the Web Service methods take SchedulerInfo as first parameter, but this can be replaced by any classimplementing ISchedulerInfo. This allows you to send additional information from the client to the web service.

caution

Your ISchedulerInfo implementation must be deserializable by JavaScriptSerializer(ASP.NET AJAX Web Services) or DataContractSerializer(WCF Services).

  1. Create a custom ISchedulerInfo implementation by inheriting from SchedulerInfo:

    C#

    public class MySchedulerInfo : SchedulerInfo
    {
       public string User { get; set; }
       public MySchedulerInfo(ISchedulerInfo baseInfo, string user)
           : base(baseInfo)
       {
           User = user;
       }
        public MySchedulerInfo() {}
    }  
    

    VB

    Public Class MySchedulerInfo
     Inherits SchedulerInfo
     Public Property User() As String
      Get
       Return m_User
      End Get
      Set
       m_User = Value
      End Set
     End Property
     Private m_User As String
     Public Sub New(baseInfo As ISchedulerInfo, userParam As String)
      MyBase.New(baseInfo)
      User = userParam
     End Sub
     Public Sub New()
        End Sub
    End Class 
    
  2. Populate the MySchedulerInfo properties in one of the following client-side events:

    For example:

    C#

    function appointmentsPopulating(sender, eventArgs)
    {
       eventArgs.get_schedulerInfo().User = "UserA";
    } 
    
  3. Change the corresponding Web Service method to take MySchedulerInfo as parameter:

    C#

    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
    {
        // Access schedulerInfo.User
        return Controller.GetAppointments(schedulerInfo);
    }
    

    VB

    Public Function GetAppointments(schedulerInfo As MySchedulerInfo) As IEnumerable(Of AppointmentData)
        ' Access schedulerInfo.User
        Return Controller.GetAppointments(schedulerInfo)
    End Function
    

Note that the schedulerInfo will be forwarded to the underlying provider. In order to access it you mustimplement the provider methods that take ISchedulerInfo as parameter. These methods were introduced in the Q3 2010release. For more information see Sending additionalinformation to the provider.

See Also