问题描述
大家好,
我编写了C#WCF服务,该服务可扫描路径并返回所有文件.现在,如果我扫描相对较小的内容,例如我的文档",它就可以正常工作.但是,当我尝试扫描C:\驱动器时,在WCF测试客户端中出现以下错误:
Hi all,
Ive written a C# WCF Service that scans a path and returns all the files. Now it works fine if I scan something relatively small, for example - My Documents. But when I try to scan the C:\ drive I get the following error in the WCF Test Client:
The request channel timed out while waiting for a reply after 00:00:59.9844000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace:
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IService1.ReturnAllFiles(CompositeType c)
at Service1Client.ReturnAllFiles(CompositeType c)
Inner Exception:
The HTTP request to ''http://localhost:56847/Service1.svc'' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
Inner Exception:
The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
现在,如果我在代码中使用断点,则可以看到代码成功,似乎响应已超时.我已经为超时等修改了配置文件中的绑定设置,但似乎无法解决它.
这是我进行的WCF服务的首次尝试,所以请放轻松!
任何建议将不胜感激.
谢谢,
Jib
Now if I use breakpoints in the code I can see that the code is successful, it just seems that the response is timing out. I''ve amended the binding settings in the config file for timeouts etc, but I don''t seem to be able to resolve it.
This is the first attempt at a WCF service I''ve made so please go easy on me!
Any suggestions would be thoroughly appreciated.
Thanks,
Jib
推荐答案
private void ConfigureClientEndPoint(ServiceEndpoint endPoint)
{
foreach (OperationDescription operation in
endPoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractBehavior =
operation.Behaviors.Find<DataContractSerializerOperationBehavior>();
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = 2147483647;
}
}
}
这篇关于WCF服务未正确调用(超时问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!