ASP.NET4.0アプリケーションがあります。
.svc
Webサービスは、ソースをリンクするファイルを使用してホストされます(サービスの実装)。Webサービス.svc
ファイルはWebServs
、アプリケーションルートディレクトリのディレクトリ内にありますMyApp/WebServs/mysvc.svc
。
Webサービスは、Web.config
(ルートディレクトリ内の)を使用して設定されます。
<!-- Service model -->
<system.serviceModel>
<services>
<service name="DataAccessService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_ISRV"
contract="MyNamespace.ISRV">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_ISRV" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="1310720"
maxArrayLength="16384"
maxBytesPerRead="24096"
maxDepth="10000"
maxNameTableCharCount="16384"/>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
わかった!
Webサービスを呼び出すときは、この一般的に使用されるロジックをカプセル化するために、ルーチンを使用してチャネルを作成します。
public static ISRV GetService() {
try {
// Create the service endpoint
BasicHttpBinding bhttpb = new BasicHttpBinding(
BasicHttpSecurityMode.TransportCredentialOnly);
bhttpb.MaxReceivedMessageSize = 2147483647;
bhttpb.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
bhttpb.ReaderQuotas.MaxArrayLength = 16384);
bhttpb.ReaderQuotas.MaxBytesPerRead = 24096);
bhttpb.ReaderQuotas.MaxDepth = 10000);
bhttpb.ReaderQuotas.MaxNameTableCharCount = 16384);
bhttpb.ReaderQuotas.MaxStringContentLength = 1310720);
ServiceEndpoint httpEndpoint =
new ServiceEndpoint(
ContractDescription.GetContract(typeof(ISRV)),
bhttpb,
new EndpointAddress());
// Create channel factory and get proper channel for service.
ChannelFactory<ISRV> channelFactory = new ChannelFactory<ISRV>(httpEndpoint);
IDAS svc = channelFactory.CreateChannel();
return svc;
} catch (Exception e) {
throw new DASException("DAS Exception: " + e.Message);
}
}
このルーチンはクライアントによって呼び出されます。WhilkeはWeb.config
、サービスサーバー側を構成するために使用されます。
大きなメッセージ(小さなメッセージでも大丈夫)でサービスを実行しようとすると、次のようになります。
フォーマッタは、メッセージを逆シリアル化しようとしたときに例外をスローしました。パラメータ http://((Namespace)):((Operation))を逆シリアル化しようとしたときにエラーが発生しました。InnerExceptionメッセージは次のとおりです。'タイプ((Type))、App_Code.s5qoir2n、Version = 0.0.0.0、Culture = neutral、PublicKeyToken=null]]のオブジェクトの逆シリアル化中にエラーが発生しました。XMLデータの読み取り中に、文字列コンテンツの最大長クォータ(8192)を超えました。このクォータは、XMLリーダーの作成時に使用されるXmlDictionaryReaderQuotasオブジェクトのMaxStringContentLengthプロパティを変更することで増やすことができます。31行目、1309位。詳細については、InnerExceptionを参照してください。
わからない。サービスとクライアントの両方に共通の設定があり、これはデフォルト値を読み取りますか????? さらに、他の多くのユーザーがここStackOverflowの手順に従って実行しました。
私を助けてください。ありがとうございました