简体   繁体   English

无法通过Web服务上传超过1MB的文件

[英]Cannot upload a file through webservice that is over 1MB

Could some take a look at my web.config and tell me what is wrong with it? 可以看看我的web.config并告诉我这是什么问题吗? I am just not able to upload a file through a remote webservice that is larger than 1MB. 我只是无法通过大于1MB的远程网络服务上传文件。 I am guessing it has something to do with the attribute settings, but so far I havent had any luck changing the values. 我猜想它与属性设置有关,但是到目前为止我还没有运气来更改值。 Or is it the setting on the host server side that I can't override? 还是我无法覆盖的主机服务器端设置?

     <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <add key="CategoryPath" value="QA/ProcessValidation"/>
      </appSettings>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
      </startup>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_Authentication" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                <message clientCredentialType="UserName" algorithmSuite="Default"/>
              </security>
            </binding>
            <binding name="BasicHttpBinding_DocumentManagement" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                <message clientCredentialType="UserName" algorithmSuite="Default"/>
              </security>
            </binding>
            <binding name="BasicHttpBinding_ContentService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                <message clientCredentialType="UserName" algorithmSuite="Default"/>
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
        </client>
      </system.serviceModel>
      <system.web>
        <compilation debug="true"/>
      </system.web>
    </configuration>

EDIT: I have no control for the service on the server side, I am actually only using the WCF and I only have the links to them. 编辑:我无法控制服务器端的服务,实际上我只在使用WCF,并且只有它们的链接。

It's not entirely clear whether the config file you posted is the client config or the server config, but it I'm going to make a semi-educated guess and say it's the client config, and you're using your client to connect to a third-party service. 尚不清楚您发布的配置文件是客户端配置还是服务器配置,但是我将做一个半基础的猜测,并说这是客户端配置,并且您正在使用客户端连接到客户端配置。第三方服务。

Without knowing the error message and/or behavior you're seeing, or how you're creating the client in code, there are a few things you can try: 在不知道错误消息和/或行为,或如何在代码中创建客户端的情况下,可以尝试以下操作:

  1. Increase the size of the maxStringContentLength attribute in the <readerQuotas> element. 增加<readerQuotas>元素中maxStringContentLength属性的大小。 Right now it is set to the default of 8,192 bytes. 现在,它被设置为默认的8,192字节。
  2. If this is the service config, increase the maxReceivedMessageSize attribute in the <binding> element - right now it is also set to the default of 65536. 如果这是服务配置,请增加<binding>元素中的maxReceivedMessageSize属性-现在将其也设置为默认值65536。

The maximum value for both of these attributes is Int32.MaxValue - roughly 2GB. 这两个属性的最大值是Int32.MaxValue大约2GB。 In either case, unless you have an endpoint specified in the config file (which you don't appear to currently) which references the defined binding config (via the <endpoint> element's bindingConfiguration attribute), you will always get the default values for the endpoint's binding. 无论哪种情况,除非您在配置文件中指定了一个端点(您目前似乎没有),该<endpoint>都引用了已定义的绑定配置(通过<endpoint>元素的bindingConfiguration属性),否则您将始终获得该<endpoint>的默认值。端点的绑定。

So you will need to either make the binding definition the default (by omitting the name attribute from the <binding> element, or you will need to assign the binding configuration you want to use by using the bindingConfiguration attribute on the endpoint, like this: 因此,您将需要使绑定定义成为默认值(通过从<binding>元素中省略name属性,或者需要通过在端点上使用bindingConfiguration属性来分配要使用的绑定配置,如下所示:

<endpoint address="" binding=basicHttpBinding"
          bindingConfiguration="MyBinding" contract="MyService.IMyService" />

If the service is not under your control, then you will not be able to do much if they have low limits set, as the client cannot modify the service's configuration (and the service cannot modify the client's either). 如果该服务不受您的控制,那么如果它们设置的限制很低,您将无法做很多事情,因为客户端无法修改服务的配置(并且服务也不能修改客户端的配置)。 The configurations are separate, but many parts (binding, security, etc) have to match. 配置是分开的,但是许多部分(绑定,安全性等)必须匹配。

If the above doesn't help, please edit your question to add more info (what error message/behavior are you seeing, is it the client or service config, how are you creating the client, do you have the service config, etc). 如果上述方法无济于事,请编辑问题以添加更多信息(您看到的错误消息/行为是客户端还是服务配置,如何创建客户端,是否拥有服务配置,等等) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM