【问题标题】:How can we Call method=post in the wcf service url?我们如何在 wcf 服务 url 中调用 method=post?
【发布时间】:2011-04-14 17:52:50
【问题描述】:
[WebGet(UriTemplate = "/{year}/{issue}/{article}")]
Article GetArticle(string year, string issue, string article);

[OperationContract]
[WebInvoke(UriTemplate = "/{year}/{issue}",Method="POST")]
Article AddArticle(string year, string issue, Article article);

我的网址是http://localhost:1355/Issues.svc/

如果我给出这个,我将从数据库中获取所有数据

http://localhost:1355/Issues.svc/2010/June/A

GetArticle 方法触发过滤后的数据以从 db 中获取。

同样,我必须调用 Add Article(WebInvoke) 方法将数据插入数据库。 我应该如何在浏览器中调用这个方法我的 url 应该是怎样的

【问题讨论】:

    标签: asp.net wcf


    【解决方案1】:
    • 将使用 jquery 的网页写入post 到您文章的 JSON 页面。
    • 使用 Fiddler 构建请求。请参阅herehere

    【讨论】:

      【解决方案2】:

      您不能仅通过访问 URL 来发帖。这就是 WebGet 的意思,你用浏览器访问它。要发布您需要编写一个小的虚拟 html 表单页面。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-06-24
        • 1970-01-01
        • 2012-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-07
        相关资源
        最近更新 更多