WCF服务返回HTTP 200头,然后超时而不返回任何内容
我有一个Silverlight 4用户控件,它调用驻留在ASP.NET 4 Web应用程序中的WCF服务。WCF服务返回HTTP 200头,然后超时而不返回任何内容
启用匿名访问web服务。 clientaccesspolicy.xml已准备好并且已成功下载。正确导航到服务器上的FieldITDbService.svc会提取服务元数据。
然而,当我尝试查看测试页面调用该WCF服务的Silverlight控件,服务本身返回:不返回数据
HTTP/1.1 200 OK
Date: Thu, 22 Jul 2010 21:15:54 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Encoding: gzip
Content-Length: 4409
Cache-Control: private
Content-Type: application/soap+msbin1
然后超时。我很困惑。有谁知道为什么会发生这种情况,或者我可以如何更有效地进行调试?我跟踪记录服务,但日志中没有错误 - 根据日志,它正在工作。
这里的显示会发生什么的链接(来自Fiddler2):http://imgur.com/VwgqS.png
下面是MainPage.xaml.cs中调用WebService的代码:
var webService = new FieldITDbServiceClient();
webService.ReadVAMDataCompleted += webService_ReadVAMDataCompleted;
webService.ReadVAMDataAsync();
webService.CloseAsync();
这里是ClientConfig在Silverlight项目用来调用web服务:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_FieldITDbService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://[ipofmyserverhere]/FieldIT/FieldITDBService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_FieldITDbService"
contract="DbServiceRef.FieldITDbService" name="CustomBinding_FieldITDbService" />
</client>
</system.serviceModel>
这是在实际WCF服务的代码,FieldITDbService.svc:
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class FieldITDbService
{
[OperationContract]
public List<VAM> ReadVAMData()
{
List<VAM> allData = new List<VAM>();
using(FieldITEntities dbContext = new FieldITEntities())
{
allData.AddRange(dbContext.VAMs.ToList());
}
return allData;
}
}
这里是在纸幅的serviceModel部应用程式web.config文件:
<system.serviceModel>
<diagnostics>
<messageLogging maxMessagesToLog="100"
logEntireMessage="true"
logMessagesAtServiceLevel="true"
logMalformedMessages="true"
logMessagesAtTransportLevel="true">
</messageLogging>
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="FieldIT.FieldITDbService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="FieldIT.FieldITDbService">
<endpoint address="" binding="customBinding" bindingConfiguration="FieldIT.FieldITDbService.customBinding0"
contract="FieldIT.FieldITDbService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
切换到客户机HTTP处理通过将线
WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
在的MainPage()构造立即解决此问题并适用于所有浏览器。我不知道为什么或如何,但我只是想接受它并继续前进。
http://msdn.microsoft.com/en-us/library/dd920295%28v=VS.95%29.aspx
在所有其他浏览器中是否超时? – 2010-07-26 20:55:15
它在IE浏览器(我认为Chrome,但我只测试一次,并没有真正记得),但从来没有在Firefox中简要工作。在过去的三天中,这三项都是超时的。 – 2010-07-26 21:19:17
如果您注释掉'CloseAsync',还会发生吗?对我来说,这只是看起来不对,你为什么要调用关闭你还没有完成使用的对象(异步读取还没有完成)? – AnthonyWJones 2010-07-23 08:27:21
是的,CloseAsync似乎根本不会改变服务的行为(它仍然在它的localhost上工作)。 – 2010-07-23 17:29:14