2013-01-24 60 views
0

我有一个简单的WCF服务,它在指定为param的位置创建一个目录。 该服务作为Windows服务托管,并以管理员帐户运行。在WCF中实现排队

InstanceContextMode是单一的,并发性也是如此。

该方法创建后返回目录位置的字符串。

客户端正在使用ASP.NET从另一台计算机访问此服务。 他有一个用例,他在几秒钟内多次点击页面上的按钮,例如在2秒内点击5次。发生什么事是该服务创建只有2或3个文件夹不是全部5.

我知道有一个默认的排队机制在WCF和我的服务它要么不工作,或者我没有写它使用该机制。

我该如何解决这个问题。

下面是按钮的ASP.NET代码点击

protected void Button1_Click(object sender, EventArgs e) 
{ 
    ClientClass objClientClass = new ClientClass(); 

    string returnValue = string.Empty; 
    Random random = new Random(); 

    string uid = random.Next().ToString(); 
    returnValue = objClientClass.StartWorkflow(uid); 
    Label1.Text = returnValue; 

} 

这里的主机的app.config:

<configuration> 
    <system.diagnostics> 
    <sources> 
    <source name="System.ServiceModel" 
       switchValue="All" 
       propagateActivity="true"> 
    <listeners> 
     <add name="traceListener" /> 
    </listeners> 
    </source> 
    <source name="System.ServiceModel.MessageLogging" 
       switchValue="All" 
       propagateActivity="true"> 
    <listeners> 
     <add name="traceListener" /> 
    </listeners> 
    </source> 
</sources> 
<sharedListeners> 
    <add name="traceListener" 
      type="System.Diagnostics.XmlWriterTraceListener" 
      initializeData="Traces.svclog" /> 
</sharedListeners> 

</system.diagnostics> 
<system.web> 
<compilation debug="true"></compilation> 
</system.web> 
<system.serviceModel> 
    <diagnostics> 
    <messageLogging logEntireMessage="true" 
        logMessagesAtServiceLevel="false" 
        logMessagesAtTransportLevel="false" 
        logMalformedMessages="true" 
        maxMessagesToLog="5000" 
        maxSizeOfMessageToLog="2000"> 
    </messageLogging> 
</diagnostics> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="NewBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="5" maxConcurrentInstances="5" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service behaviorConfiguration="NewBehavior" name="Utilities.WS.SampleWebService.Jobs"> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" 
     contract="Utilities.WS.SampleWebService.IJobs" /> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    <host> 
     <baseAddresses> 
     <add  baseAddress="http://00.00.000.00:8732/Utilities.WS.SampleWebService.Jobs" /> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 
</system.serviceModel> 
</configuration> 

问候。

+1

启用您的服务跟踪,看看有多少信息没有您的服务收到。那么你会明白,天气问题是在你的asp端或WCF端 – Alex

+0

嗨@voo,我启用了跟踪。 svcLog显示该服务从5次点击中只收到3次请求,我可以看到3次请求的结果。那么余下的2发生了什么? – Codehelp

+1

在我看来,这个问题并不在你的服务中。它可以在你的Button1_Click处理程序中吗?我的意思是你可以点击5次,但它只会触发3次。并尝试更改您的限制中的MaxConcurrentCalls(当前正在执行的服务的调用次数) – Alex

回答

0

第1步。从客户端(服务器端ASP.NET代码,而不是浏览器)ping,它可以到达托管WCF服务的计算机吗?防火墙位于Web服务器和WCF的托管位置之间?

STEP 2. SVC日志 设置svclog从您的配置文件,

<configuration> 
    <system.diagnostics> 
     <sources> 
      <source name="System.ServiceModel" 
        switchValue="Information, ActivityTracing" 
        propagateActivity="true"> 
      <listeners> 
       <add name="traceListener" 
        type="System.Diagnostics.XmlWriterTraceListener" 
        initializeData= "c:\log\Traces.svclog" /> 
      </listeners> 
     </source> 
     </sources> 
    </system.diagnostics> 
</configuration> 

然后从命令提示符下使用SvcTraceViewer - 寻找红色。

STEP 3.添加一些记录到你的操作并查看是否有实际执行

http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx