我目前正在使用带有实体框架的WCF数据服务(其实是ADO.Net数据服务),在执行POST时出现了以下错误(省略/更改了一些不相关的信息):
<?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
}
}
感谢。
编辑:我似乎在这方面没有进展。以下是我迄今为止尝试过的内容。
在服务器端,我设置了以下绑定:
<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
属性可以解决问题。这些绑定看起来正确吗?我是否缺少某个属性,以便让我向服务器POST更多数据?我是否还需要在客户端上配置此服务行为?