将传输模式更改为“流式传输”后无法加载 WCF Restful 帮助页面

发布于 2024-11-06 02:55:22 字数 1225 浏览 5 评论 0原文

在我的项目中,有一个 wcf Restful 服务,它允许用户将照片上传到 Web 服务。

更改配置设置以允许大文件上传后。 (添加绑定配置,即“TransferMode”、“BufferSize”等) 所有运营合同均按预期运行。

但是,端点的服务帮助页面停止工作。

一旦我删除端点上的绑定配置设置,帮助页面就会返回,

如何修复此问题?我在哪里错过了

谢谢大家

<bindings>
          <webHttpBinding>
              <!-- buffer: 64KB; max size: 64MB -->
              <binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" 
                       maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
              </binding>
          </webHttpBinding>
</bindings>

<service name="WCFRestFul.ApiRestful">
        <endpoint address="" binding="webHttpBinding"
                  bindingConfiguration="StreamedBinding" bindingName="StreamedBinding" 
                  contract="WCFRestFul.IApiRestful" behaviorConfiguration="web" />
 </service>

更新: 我认为这不仅仅是因为传输模式,也许还有其他一些设置。 一旦我删除上面代码中的“bindingConfiguration”,服务帮助页面就会返回。 我有 2 个端点。另一个端点没有“绑定配置”,并且服务帮助页面可以正常工作。 我肯定错过了这里的一些东西,也许是一些简单的东西。 任何帮助将不胜感激

In my project, a wcf restful service, which allow users to upload photos to the web service.

After changing config settings to allow large file upload. (add binding configuration, i.e. "TransferMode", "BufferSize", etc.)
All Operation contracts are all working as expected.

However, the service help page for the endpoint stopped working.

The help page comes back, once I remove the binding config setting on my endpoint

How can I fixed this?? where did i missed

thank you all

<bindings>
          <webHttpBinding>
              <!-- buffer: 64KB; max size: 64MB -->
              <binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" 
                       maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
              </binding>
          </webHttpBinding>
</bindings>

<service name="WCFRestFul.ApiRestful">
        <endpoint address="" binding="webHttpBinding"
                  bindingConfiguration="StreamedBinding" bindingName="StreamedBinding" 
                  contract="WCFRestFul.IApiRestful" behaviorConfiguration="web" />
 </service>

Update:
I think it is not just because of the transfer mode, but maybe some other setting as well.
The service help page comes back once I remove the "bindingConfiguration" in the code above.
I have 2 endpoints. The other endpoint don't have the "bindingConfiguration", and the service help page works fine on that.
I definitely missed some thing here, maybe some thing simple.
any help will be greatly appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风不识月 2024-11-13 02:55:22

我采纳了 carlosfigueira 的建议,痛苦地一次删除了一个配置设置。

我将配置设置从

旧代码

<bindings>
          <webHttpBinding>
              <!-- buffer: 64KB; max size: 64MB -->
              <binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" 
                       maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
              </binding>
          </webHttpBinding>
</bindings>

更改为最终工作版本(transferMode="Streamed"已删除),

<bindings>
 <webHttpBinding>
<binding name="StreamedBinding" maxReceivedMessageSize="67108864" />
 </webHttpBinding>
</bindings>

最后服务帮助页面又回来了。

但是我不明白为什么它会恢复与关闭的原因相同。

无论如何,这是适合我的情况的可行解决方案。
希望有人会觉得它有帮助。

I took carlosfigueira advice, painfully removed my config setting one at a time.

I changed my config settings from

OLD Code

<bindings>
          <webHttpBinding>
              <!-- buffer: 64KB; max size: 64MB -->
              <binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" 
                       maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
              </binding>
          </webHttpBinding>
</bindings>

To Final working version (transferMode="Streamed" is removed)

<bindings>
 <webHttpBinding>
<binding name="StreamedBinding" maxReceivedMessageSize="67108864" />
 </webHttpBinding>
</bindings>

finally the service help page is back.

However I can't understand why it is back same as why it was turned off.

anyway, this is the working solution for my case.
hope someone would find it helpful.

情释 2024-11-13 02:55:22

你说它停止工作是什么意思?在下面的示例中,服务仍然返回帮助页面(我尝试使用 IE 和 Chrome,他们能够看到该页面)。

    public class StackOverflow_5937029
{
    [ServiceContract]
    public interface ITest
    {
        [WebGet]
        int Add(int x, int y);
    }
    public class Service : ITest
    {
        public int Add(int x, int y)
        {
            return x + y;
        }
    }
    static void SendRequest(string address)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(address);
        req.Method = "GET";

        HttpWebResponse resp;
        try
        {
            resp = (HttpWebResponse)req.GetResponse();
        }
        catch (WebException e)
        {
            resp = (HttpWebResponse)e.Response;
        }

        Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
        foreach (string headerName in resp.Headers.AllKeys)
        {
            Console.WriteLine("{0}: {1}", headerName, resp.Headers[headerName]);
        }

        Console.WriteLine();
        Stream respStream = resp.GetResponseStream();
        Console.WriteLine(new StreamReader(respStream).ReadToEnd());

        Console.WriteLine();
        Console.WriteLine("  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*  ");
        Console.WriteLine();
    }
    public static void Test()
    {
        string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
        ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
        WebHttpBehavior behavior = new WebHttpBehavior
        {
            HelpEnabled = true
        };
        WebHttpBinding binding = new WebHttpBinding
        {
            TransferMode = TransferMode.Streamed
        };
        host.AddServiceEndpoint(typeof(ITest), binding, "").Behaviors.Add(behavior);
        host.Open();
        Console.WriteLine("Host opened");

        SendRequest(baseAddress + "/Add?x=4&y=8");
        SendRequest(baseAddress + "/help");

        Console.Write("Press ENTER to close the host");
        Console.ReadLine();
        host.Close();
    }
}

What do you mean by saying that it stops working? In the example below the help page is still returned by the service (and I tried using both IE and Chrome, and they were able to see the page).

    public class StackOverflow_5937029
{
    [ServiceContract]
    public interface ITest
    {
        [WebGet]
        int Add(int x, int y);
    }
    public class Service : ITest
    {
        public int Add(int x, int y)
        {
            return x + y;
        }
    }
    static void SendRequest(string address)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(address);
        req.Method = "GET";

        HttpWebResponse resp;
        try
        {
            resp = (HttpWebResponse)req.GetResponse();
        }
        catch (WebException e)
        {
            resp = (HttpWebResponse)e.Response;
        }

        Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
        foreach (string headerName in resp.Headers.AllKeys)
        {
            Console.WriteLine("{0}: {1}", headerName, resp.Headers[headerName]);
        }

        Console.WriteLine();
        Stream respStream = resp.GetResponseStream();
        Console.WriteLine(new StreamReader(respStream).ReadToEnd());

        Console.WriteLine();
        Console.WriteLine("  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*  ");
        Console.WriteLine();
    }
    public static void Test()
    {
        string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
        ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
        WebHttpBehavior behavior = new WebHttpBehavior
        {
            HelpEnabled = true
        };
        WebHttpBinding binding = new WebHttpBinding
        {
            TransferMode = TransferMode.Streamed
        };
        host.AddServiceEndpoint(typeof(ITest), binding, "").Behaviors.Add(behavior);
        host.Open();
        Console.WriteLine("Host opened");

        SendRequest(baseAddress + "/Add?x=4&y=8");
        SendRequest(baseAddress + "/help");

        Console.Write("Press ENTER to close the host");
        Console.ReadLine();
        host.Close();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文