如何接收大文件从安卓应用程序到我的wcf服务?坏的请求

本文关键字:服务 wcf 我的 请求 应用程序 何接收 文件 | 更新日期: 2023-09-27 18:15:50

我看过很多web上的配置。配置,但我仍然不能传递一个大的图像到我的WCF服务我试过这个链接如何解决WCF中的400个坏请求错误,但我没有c#的客户端…

我的客户端来自android;

这是我的代码在web.config
<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings>
        <add name="ULIVConnectionString" connectionString="Data Source=PHMDUASSVR1;Initial Catalog=CITBuddyDB;Persist Security Info=True;User ID=ulappstore;Password=ulappadmin" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding maxBufferSize="64000000" maxReceivedMessageSize="64000000" maxBufferPoolSize="64000000">
                    <readerQuotas maxDepth="64000000" maxStringContentLength="64000000" maxArrayLength="64000000" maxBytesPerRead="64000000" />
                    <security mode="None"/>
                </binding>
            </basicHttpBinding>
        </bindings>
        <services>
            <service name="CITBuddy.CITServiceFunctions" behaviorConfiguration="CITBuddy.CITServiceFunctionsBehavior">
                <!-- Service Endpoints -->
                <endpoint address="../CITServiceFunctions.svc" binding="webHttpBinding" contract="CITBuddy.CITServiceURL" behaviorConfiguration="webBehaviour"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="CITBuddy.CITServiceFunctionsBehavior">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="webBehaviour">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
        </modules>
    </system.webServer>
    <system.web>
        <httpRuntime maxRequestLength="2097151" executionTimeout="7200" />
        <compilation debug="true" targetFramework="4.0">
        </compilation>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
</configuration>

如何接收大文件从安卓应用程序到我的wcf服务?坏的请求

试试这个(注意transferMode="StreamedRequest"很重要):

<service behaviorConfiguration="Default" name="....">
    <endpoint address="" behaviorConfiguration="Web" binding="webHttpBinding"
      bindingConfiguration="LargeWeb" contract="..." />
    <host>
      <baseAddresses>
        <add baseAddress="..." />
      </baseAddresses>
    </host>
</service>
<webHttpBinding>
    <binding name="LargeWeb"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647"
             maxReceivedMessageSize="2147483647"
             transferMode="StreamedRequest">
      <readerQuotas
            maxDepth="2147483647"
            maxStringContentLength="2147483647"
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxNameTableCharCount="2147483647"/>
    </binding>
  </webHttpBinding>