wcf测试客户端不支持此操作,因为它使用类型system.io.stream

时间:2013-08-29 23:36:05

标签: c# wcf web-services

当我运行示例WCF应用程序时,我在WCF测试客户端窗口中收到以下错误

This operation is not supported in the wcf test client because it uses type system.io.stream

我有ping方法,在我的服务实现中使用Stream。

 public string Ping(Stream input)
        {
            var streamReader = new StreamReader(input);
            string streamString = streamReader.ReadToEnd();
            streamReader.Close();
            NameValueCollection nvc = HttpUtility.ParseQueryString(streamString);
            return string.IsNullOrEmpty(nvc["message"])
                ? "The 'message' key value pair was not received."
                : nvc["message"];
        }

在我的web.config文件中添加了

<basicHttpBinding>
        <binding name="HttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed" > </binding>
      </basicHttpBinding>

允许直播。现在,当我运行应用程序时,我得到上述错误。我用Google搜索并研究了很多。我使用fiddler来追踪错误,它是http错误415,它确认了来自WCF测试客户端的上述错误。

更新 这是我的服务合同

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebInvoke(UriTemplate = "ping")]
    string Ping(Stream input);
}

我使用的卷曲命令

curl -x 127.0.0.1:8888 http://localhost:8000/Service1.svc/ping -d message=pong

注意-x 127.0.0.1:8888供fiddler捕获流量

这是小提琴结果

# Result Protocol Host URL Body Caching Content-Type    Process Comments    Custom  
1 415   HTTP    localhost:8000  /Service1.svc/ping  0   private     curl:7440

0 个答案:

没有答案