1

WCF を使用して 50MG ファイルをアップロードする最良の方法は何ですか?

MTOMが自動的に処理してくれると思っていました。
私が間違っていたと思います...

LocalHost で実行していても例外が発生します
(外部 IIS を使用するのはさらに悪いと思います)。

例外メッセージ:

「 http://localhost:7064/DataSyncService.svcへの HTTP 応答を受信中にエラーが発生しました 。これは、サービス エンドポイント バインディングが HTTP プロトコルを使用していないことが原因である可能性があります。これは、HTTP 要求コンテキストが中止されたことが原因である可能性もあります。 (おそらくサービスのシャットダウンが原因です。詳細については、サーバー ログを参照してください。)

サーバー構成:

    <system.serviceModel>
    <client>
        <remove contract="IMetadataExchange" name="sb" />
    </client>
    <bindings>
        <wsHttpBinding>
            <binding name="DataSyncBinding" messageEncoding="Mtom" maxReceivedMessageSize ="50000000" maxBufferPoolSize="50000000">
                <readerQuotas maxArrayLength="50000000" />
                <security mode="None" />
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="Server.DataSyncServiceBehavior" name="Server.DataSyncService">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DataSyncBinding" name="DataSyncService"
                      contract="Server.IDataSyncService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="Server.DataSyncServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>

クライアント構成:

    <system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="DataSyncService" closeTimeout="00:05:00" openTimeout="00:05:00"
                receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false"
                transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:7064/DataSyncService.svc"
            binding="wsHttpBinding" bindingConfiguration="DataSyncService"
            contract="DataSyncServiceReference.IDataSyncService" name="DataSyncService" />
    </client>
</system.serviceModel>

ありがとうございます。

4

1 に答える 1

2

ファイルが正確に50 MB の場合、50 MB は実際には 50 * 1024 * 1024 = 52428800 バイトであるため、maxReceivedMessageSize と maxArrayLength の設定が低すぎます。また、maxReceivedMessageSIze は、データだけでなく、メッセージ自体の構造 (SOAP エンベロープなど) を考慮する必要があります。

ストリーミングを使用できます。これは、大きなファイルの場合に推奨される方法です。残念ながら、wsHttpBinding では利用できません。ストリーミングを有効にするには、basicHttpBinding や webHttpBinding などを使用する必要がある場合があります。

ストリーミングの詳細はこちら:

http://msdn.microsoft.com/en-us/library/ms733742.aspx

于 2012-03-06T01:51:24.137 に答える