【问题标题】:how to call simple wcf from fiddler如何从提琴手调用简单的 wcf
【发布时间】:2017-03-28 00:31:06
【问题描述】:

我有一个简单的 wcf 肥皂服务。在visual studio中运行它并在localhost上运行

试图从提琴手访问 GetData 方法,但它给出了错误的请求 400。我做错了什么?

http://localhost:23150/Service1.svc/GetData?value=1

获取

服务:

[服务合同] 公共接口 IService1 {

[OperationContract]
string GetData(int value);

[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);

// TODO: Add your service operations here

}

  public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

【问题讨论】:

  • 您是否将 WCF 服务公开为 RESTful 服务?例如 - codeproject.com/Articles/590627/…
  • 改用SOAP UI。
  • 我从来不知道我们可以使用 fiddler 调用 Web 服务:O.你在哪里实现了 GetData?贴出代码
  • 还添加了GETData代码
  • 当您的操作响应soap请求时,您应该使用SOAP UI。

标签: c# wcf


【解决方案1】:

尝试像这样设计您的 [OperationContract]:

[OperationContract(Name = "GetData")]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetData?value={value}")]

现在运行您的服务并从 fiddler 中选择 GET 动词并发送请求。我相信它现在可以工作了。

【讨论】:

    猜你喜欢
    • 2012-12-23
    • 1970-01-01
    • 2023-01-29
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多