我正在使用Entity Framework使用WCF数据服务(以及ADO.Net数据服务),并在执行POST时收到以下错误(省略/改变了一些无关紧要的信息):远程主机强制关闭现有连接 - WCF数据服务错误
<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code /><m:message xml:lang="en-GB">The URI 'http://localhost:56568/MyWcfDataServices.svc/EntitySetName(pk_id)' is not valid for POST operation. For POST operations, the URI must refer to a service operation or an entity set.</m:message></m:error>
有环顾四周网上,我似乎无法找到有关此消息,以便调试它是一个有点困难多的信息。这很可能是因为我发布的一个属性是一个大型的base64字符串(如果我不发布这个,它可以正常工作)。我已经尝试设置maxRequestLength
以下几点:
<httpRuntime maxRequestLength="102400" />
但它似乎并没有帮助。虽然我会继续努力完成这个任务,但我认为我会在这里做一个快速发布,看看是否有人知道可能有帮助的事情。
我的WCF数据服务类看起来是这样的:
public class MyWcfDataServices: DataService<ContextName>
{
public static void InitializeService(DataServiceConfiguration config)
{
// set entity access rules etc
}
}
感谢
编辑:我似乎没有要与此Anywhere入门。这是迄今为止我尝试过的。
在服务器端我已经设置以下绑定:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
minFreeMemoryPercentageToActivateService="0" />
<services>
<service name="MyWcfDataServices"
behaviorConfiguration="myBehaviorConfig">
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration=""
contract="System.Data.Services.IRequestHandler" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myBehaviorConfig">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
希望的maxItemsInObjectGraph
属性将是解决办法。这些绑定看起来是否正确?我是否缺少一些可让我将更多数据发布到服务器的属性?我是否也需要在客户端上配置此服务行为?
你应该得到两个upvotes,一个用于答案,一个用于“少发”的笑话。唉,我只能赞成一次。 –