質問

んWCF RESTサービスを開催IIS。純4RC.のポストへの通話サービスを直列化をJSON.べての動作までのサイズのDataMember(文字列)は以8K.この場合は受信のエラー以下を示すMaxStringContentLengthを超えています。のmaxStringContentLength属性の評価項目していますが、正確にはから読み取られたconfigファイルです。

Webコンフィグである:

<services>
  <service name="MyServiceServer" >
    <endpoint address="http://localhost/MyService" kind="webHttpEndpoint" endpointConfiguration="serviceEndPoint" contract="IMyService">
    </endpoint>
  </service>
</services>

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="serviceEndPoint" maxReceivedMessageSize="2048000"  maxBufferSize="2048000" maxBufferPoolSize="0">
      <readerQuotas maxStringContentLength="2048000" maxArrayLength="2048000"  maxDepth ="65000"/>
      <security mode="None">
        <transport clientCredentialType="None"/>
      </security>
    </standardEndpoint>
  </webHttpEndpoint>
</standardEndpoints>

IMyServiceインタフェースに定義されている。

public interface IMyService
{
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/request", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    void MyMehod(<Class Type> obj);
}

完全にエラーメッセージ:

"サーバーのエラーがあった処理に対応いたします例外のメッセージは"誤りがありましたdeserializingのオブジェクトのタイプです。最大文字列コンテンツの長さを募集人員(8192)を超えていながらXMLを読み込むデータです。この定員が増加しに変更するMaxStringContentLength性のXmlDictionaryReaderQuotasオブジェクトを作成するときに使用しますのXMLリーダーを用'.参照のサーバーログになります。例外のスタックトレースは:です。を行います。直列化します。XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegatorリーダー,Boolean verifyObjectName,DataContractResolver dataContractResolver)です。を行います。直列化します。Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReaderリーダー,Boolean verifyObjectName)です。ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(メッセージmessage,Object[]パラメータ)です。ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(メッセージmessage,Object[]パラメータ)です。ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(メッセージmessage,Object[]パラメータ)です。ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&rpcです。ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&rpcです。ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&rpcです。ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&rpcです。ServiceModel.Dispatcher.MessageRpc.プロセス(Boolean isOperationContextSet)"

役に立ちましたか?

解決

この作品は、必ず完全に絶対URLとしてご評価項目アドレスです。まcraftyして相対パス、またはを省略した場合.svcで原爆の不思議なリーダーやエラーを一度の要求が大きすぎて--

いファイルのこのバグのためのWCFでのいずれかの

  1. 相対Urlは許可(適切なスローされる例外です)

または

  1. 読者のクォーターと協働しなければならな相対パスとして

他のヒント

あなたのweb.configファイルに挿入します:

<configuration>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBindingConfig">
          <readerQuotas maxStringContentLength="2048000" />
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

と、あなたのエンドポイントに属性bindingConfiguration = "webHttpBindingConfig" を挿入

また同様の問題です。純3.5

私は問題ないサーバのログの問題があったのです。ように構成で最大値を増加しませんでした読み活用する...

いる名前を渡すの評価項目を明示的にコンストラクタのWebChannelFactory、他る。

した:

WebChannelFactory<IWKRestTest> factory = new WebChannelFactory<IWKRestTest>(new Uri(XXX));
factory.Credentials.UserName.UserName = K_USERNAME;
factory.Credentials.UserName.Password = K_PASSWORD;
IWKRestTest proxy = factory.CreateChannel();

WebChannelFactory<IWKRestTest> factory = new WebChannelFactory<IWKRestTest>("IWKRestTestService");

のアプリです。configり:

のUriを記載した評価項目のノードがただくものbindingConfigurationのれんの増加限度現。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top