[英]Why can't my WCF Client connect to my WCF Service?
我已经开发了WCF服务,但是从客户端连接到它时遇到了问题。
我可以在浏览器中看到服务的wsdl
,但是当我尝试通过WCF客户端连接服务时,出现以下错误消息:
在指定的00:23:59.5339734超时内,打开操作未完成。 分配给该操作的时间可能是较长超时的一部分。
以下是我的客户端app.config详细信息:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IService" closeTimeout="00:25:00" openTimeout="00:24:00" receiveTimeout="00:15:00" sendTimeout="00:25:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="409600" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:25:00"/>
<security mode="None">
<!--<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>-->
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://silcore.co.in/Service.svc"
binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IService"
contract="IService"
name="WSDualHttpBinding_IService">
<identity>
<dns value="http://silcore.co.in"/>
</identity>
</endpoint>
</client>
这是超时错误的堆栈跟踪:
at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
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 System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Open()
at WCF_Client.Program.Main(String[] args)
服务器端web.congif文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" defaultLanguage="c#" />
<customErrors mode="Off" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="Service.svc" />
</files>
</defaultDocument>
</system.webServer>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="DualNewBinding" />
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="HostWCF.ServiceBehavior" name="HostWCF.Service">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DualNewBinding" contract="HostWCF.IService">
<identity>
<dns value="silcore.co.in" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://silcore.co.in/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HostWCF.ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
我想说该服务背后的操作确实需要很长时间。 预计需要超过24分钟吗? 如果是这样,请增加超时时间,或者也许应该使该操作异步。
如果预计无法使用24分钟,请尝试更改操作以立即返回。 现在可以用吗? 如果是,那么您的操作将花费很长时间,您需要了解操作方法和原因。
如果没有,则可能是防火墙/网络问题。 服务器或中间的某个人可能不会拒绝您的连接,而只是忽略它。 要调试此功能,请暂时停用安全性。 另外,请确保是否在服务器端收到了该请求。 放置一个断点或记录所有传入的请求。
希望能有所帮助
我认为您需要在客户端配置中增加OpenTimeOut的值。
检查天气是否有防火墙阻止服务器上的呼叫
我也觉得服务器端的某种日志记录或网络监视工具也可以帮助您
NetMon是Microsoft提供的很好的工具。 试试看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.