受信したファイルをデータベースに保存するWebサービス(WCF)があります。.NET 4.5 Webアプリケーションから呼び出す場合は、クライアントのWeb.configファイルで指定するだけです。
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_NameOfWS"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
したがって、クライアントは大きなファイルを送信できます。
.NET 2デスクトップアプリケーション(はい、.NET 2)から呼び出そうとすると、次のエラーが表示されます。
HTTP 413: Request Entity Too Large
しかし、Webアプリケーションではないため、構成するWeb.configファイルがありません。
私のapp.configは次のようになります:
<applicationSettings>
<NameOfProject.Properties.Settings>
<setting name="NameOfProject_NameOfWebReference_NameOfWS"
serializeAs="String">
<value>http://myURL/NameOfWS.svc</value>
</setting>
</NameOfProject.Properties.Settings>
</applicationSettings>
また、NameOfWS.wsdlファイルにはmaxBufferSizeまたはmaxReceivedMessageSizeパラメーターがありません。
私は何かが足りませんか?
前もって感謝します。
解決しました!
誰かがこのような問題を解決する必要がある場合、私はそれを機能させる方法を投稿します。
私のサービスプロジェクトのWeb.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_MyWCFInterface" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<services>
<service name="MyProject.MyWCFClass" >
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_MyWCFInterface"
contract="MyProject.MyWCFInterface"/>
</service>
</services>
</system.serviceModel>
クライアントプロジェクトのApp.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_MyWCFInterface" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:myPort/MyService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_MyWCFInterface"
contract="NameOfCreatedService.MyWCFInterface"
name="BasicHttpBinding_MyWCFInterface" />
</client>
</system.serviceModel>
そして、私が知らなかった最後のステップは、クライアントのソリューションのメインプロジェクトのApp.configにこのApp.config構成をコピーすることです。そうでない場合、構成は起動時にロードされず、機能しません。メッセージサイズの構成。
私はそれが誰にでも役立つことを願っています。
この問題に時間を割いてくださった方々に感謝します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加