gpt4 book ai didi

wcf-data-services - ADO.NET 数据服务 : Passing parameter to [WebInvoke] Method

转载 作者:行者123 更新时间:2023-12-05 00:44:04 24 4
gpt4 key购买 nike

考虑以下示例:

public class SomeBusinessLayerService : DataService<MyEntityContainer>
{
[WebInvoke]
void DoSomething(string someParam)
{
}
}

我找不到关于如何将参数传递给函数的示例或任何帮助!
使用 WebClient(或 goofinfg 与 fiddler 一起使用)我可以触发函数调用,但无论我尝试什么参数 someParam 始终为空
更糟糕的是 - 如果我将类型更改为 int - 我所有的尝试都以以下错误结束:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">Bad Request - Error in query syntax.</message>
</error>

任何人都可以帮助我如何调用 POST 内容的工作示例吗?

注意:这是 DataService,而不是 WCF 服务。我可以使用相同的方法使用 WCF 服务,没有任何问题。

编辑:我还需要 POST 示例,而不是在 URI 中嵌入参数,因为 URI 有大小限制和清理字符串的要求。

最佳答案

经过几个小时的“错误请求 - 查询语法错误”响应,我终于通过在 URI 中传递参数来让它工作。

请特别注意字符串参数周围的引号:

错误:DoSomething?someParam=param 正确:DoSomething?someParam='param'

关于wcf-data-services - ADO.NET 数据服务 : Passing parameter to [WebInvoke] Method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/387895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com