Web服务不处理从代理类相同的应用程序同时进行多个请求 [英] Web service not handling multiple simultaneous request from same application with proxy class

查看:156
本文介绍了Web服务不处理从代理类相同的应用程序同时进行多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序调度这些调用不同的Web服务的多个任务,一些相同的Web服务,但不同的方法。每个任务是在时间间隔执行与每个任务在它自己的线程中运行。要获得参考web服务我有一个实例化内部每个任务和处置永诺一Wsdl.exe用生成的代理类。但是在运行应用程序时,任务实际上是在服务请求等待海誓山盟,那并不处理来自任务y坐标从Task X所对其做处理请求之前,服务请求的Web服务(我可以看到这一点,因为从Task X所服务呼叫可能需要5分钟,任务ÿ100毫秒,但是如果Y X运行时启动时,它完成100毫秒x被完成后)。

I have an application scheduling multiple tasks which are calling different web services, some the same web service but different method. Each task is executed in an interval and each task is running in its own thread. To obtain reference to the webservice I have a wsdl.exe generated proxy class which is instantiated inside each of the tasks and allways disposed. However when running the application, the tasks are actually waiting for eachother at the service requests, web service doesnt process the service request from task y before its done processing request from task x (I can see this because a service call from task x may take 5 minutes and task y 100 milliseconds, however if y is starting when x is running, it finishes 100 milliseconds after x is done).

这是代码从一个任务(自己的线程中运行):

This is code from a task (running inside its own thread):

public class TaskX : TaskWrapper
{
    public TaskX(Guid id, string name, EventQueue eventqueue)
        : base(id, name, eventqueue)
    {
    }

    protected override void DoTask()
    {

        try
        {
            var factory = new ServiceReferenceFactory();
            using (var reference = factory.GetServiceReference())
            {

                bool result;
                bool isSpecified;

                reference.Run(out result, out isSpecified);
            }
        }
    }
}

这是从工厂方法的代码上面提到的:

This is the code from the factory method mentioned above:

public ProxyClassService GetServiceReference()
    {
                    var refer = new ProxyClassServiceNamespace.ProxyClassService();
                    refer.Timeout = 1000 * 60 * 60;

                    return refer;
    }



有谁知道为什么我遇到这种行为?

Does anyone know why I'm experiencing this behaviour?

编辑:

下面是任务的一些日志我加后[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]来执行我的WCF服务。我没有做配置更改在Visual Studio 2008中创建一个WCF服务

Here is some logs from tasks after I added [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] to the implementation of my wcf service. I made none configuration changes to a wcf service created in visual studio 2008.

15时02分 - 任务开始:TaskXWithInternalException

15:02 - Task started: TaskXWithInternalException

15时02分 - 任务开始:TaskYQuickOne

15:02 - Task started: TaskYQuickOne

15时02分 - 任务结束:TaskYQuickOne
任务运行时间:00:00:00.1214762

15:02 - Task ended: TaskYQuickOne Task elapsed time: 00:00:00.1214762

15时02分 - 任务开始:TaskZSlowOne

15:02 - Task started: TaskZSlowOne

15时03分 - 任务开始:TaskXWithInternalException

15:03 - Task started: TaskXWithInternalException

15时03分 - 任务开始:TaskYQuickOne

15:03 - Task started: TaskYQuickOne

15时05分 - 任务结束:TaskZSlowOne
任务执行时间:0时03分:11.6510947

15:05 - Task ended: TaskZSlowOne Task elapsed time: 00:03:11.6510947

15时05分 - 任务结束:TaskYQuickOne
任务运行时间:00:02:09.7311905

15:05 - Task ended: TaskYQuickOne Task elapsed time: 00:02:09.7311905

15:06 - 任务开始:TaskYQuickOne

15:06 - Task started: TaskYQuickOne

15:06 - 任务结束:TaskYQuickOne
任务运行时间:00:00:00.0546980

15:06 - Task ended: TaskYQuickOne Task elapsed time: 00:00:00.0546980

推荐答案

这是可能的的并发/实例化设置你的WCF服务。

This is probably to do with the concurrency/instancing settings on your WCF service.

如果所有呼叫都将相同的服务实例(例如 InstanceContextMode = PerSession或单一),那么通常你需要确保你已经设置了 ConcurrencyMode ,否则呼叫服务以串行的方式。

If all your calls are going to the same service instance (e.g. InstanceContextMode = PerSession or Single), then typically you will need to make sure you have set the ConcurrencyMode to Multiple, otherwise the calls are serviced in a serialized fashion.

你能告诉我们更多关于如何WCF服务(而不是客户端)是设置?

Can you tell us more about how the WCF service (not client) is setup?

这篇关于Web服务不处理从代理类相同的应用程序同时进行多个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆