【问题标题】:How to receive large file from android app to my wcf service? BAD request如何从 android 应用程序接收大文件到我的 wcf 服务?错误的请求
【发布时间】:2014-07-31 08:02:50
【问题描述】:

我在 web.config 中阅读了很多配置,但我仍然无法将大图像传递给我的 wcf 服务 我试过这个链接How to resolve 400 bad request error in WCF 但我没有来自 c# 的客户端..

我的客户端来自安卓;

这是我在 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>

请帮助我..

【问题讨论】:

    标签: c# android wcf service


    【解决方案1】:

    试试这个(注意 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>
    

    【讨论】:

    • 我应该更换我的服务吗?
    • 我应该在添加 baseAddress 中添加什么
    • 我已经阅读了 msdn,如果您确定相对的 Web 服务地址,则基地址是必要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-09
    相关资源
    最近更新 更多