This is a migrated thread and some comments may be shown as answers.
Webservice binding. Serious problem with multiple simultaneous server requests
1 Answer 15 Views
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 22 May 2012, 10:35 AM
hi,

we are using the ajax scheduler in an mvc project. Looking great, good functionality, all that.
But we are encountering a serious problem.

The scheduler requires web service binding to work in an mvc page. Appointments are fed by the web service. Collecting appointments takes some time delving through the database. 

All goes well until the web-service receives a request from another user requesting for appointments while it is still working on collecting appointments for the first user. The result is that the second user will receive both the appointments for the first user and her own appointments. Which is in a multi user scenario with high demands on privacy of course absolutely inappropriate.

This scenario takes some effort to reproduce. We found the proof by adding one "debug" appointment in the GetAppointments implementation of the service. The appointment was labeled with the requesting users identification. I case of heavy load an appointment mix containing two different "debug" appoints show up in the web page. Ruling out any bugs in our appointment collecting.

At the moment I'm studying on a workaround where the OnPopulating scheduler script event will make an ajaxcall to the service to raise a Mutex. The mutex will be lowered in get appointments. Quite a freaky way to solve things, provided it will even work. For now I don't see an alternative yet.

Any help is greatly appreciated.

kind regards

Peter

1 Answer, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 22 May 2012, 02:39 PM
To answer my own question.

The venom is in the WebServiceAppointmentController, a Telerik class.

Implementing a web service is a multi stage missile which requires a provider and a controller. The provider can be cached

This works well: 
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
[System.ComponentModel.ToolboxItem(false)]
public class AgendaWebService : WebService
{
    private static AgendaProvider _agenda;
    private AgendaProvider Agenda
    {
        get { return _agenda ?? (_agenda = new AgendaProvider()); }
    }
 
    private WebServiceAppointmentController Controller
    {
        // ALWAYS create a new controller !!!!!!!!!!!!!!
        get { return new WebServiceAppointmentController(Agenda); }
    }
 
    [WebMethod]
    public IEnumerable<AppointmentData> GetAppointments(AgendaProvider.EposSchedulerInfo schedulerInfo)
    {
        return Controller.GetAppointments(schedulerInfo);
    }
}


Caching the controller as well leads to the mixup in our problem.

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
[System.ComponentModel.ToolboxItem(false)]
public class AgendaWebService : WebService
{
    private static AgendaProvider _agenda;
    private AgendaProvider Agenda
    {
        get { return _agenda ?? (_agenda = new AgendaProvider()); }
    }
 
    private static WebServiceAppointmentController _controller;
    private WebServiceAppointmentController Controller
    {
        // DON'T !!!!!!
        get { return _controller ?? (_controller = new WebServiceAppointmentController(Agenda)); }
    }
 
    [WebMethod]
    public IEnumerable<AppointmentData> GetAppointments(AgendaProvider.EposSchedulerInfo schedulerInfo)
    {
        return Controller.GetAppointments(schedulerInfo);
    }
}
 
In the end simple to fix....

Setting Mutexes and the like, as I suggested in my question, does not work. The OnClientAppointmentsPopulating does not wait for an ajax call to return

all the best

Peter



Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Share this question
or