我有wcf应用程序,它接受base64图像。它适用于内容长度约69000。 内容超过69K抛出错误。内容长度来自小提琴手。
发生了'System.ServiceModel.ProtocolException'类型的异常 在mscorlib.dll中但未在用户代码中处理
其他信息:远程服务器返回了意外情况 回复:(413)请求实体太大。
服务Web.config
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="2097152"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="userServiceBasicHttp" maxBufferPoolSize="2097152" maxReceivedMessageSize="2097152">
<readerQuotas maxDepth="2097152" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior >
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="customQuotaBehavior">
<dataContractSerializer maxItemsInObjectGraph="2097152"/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<services>
<service name="ServiceApplication.UserManagement">
<endpoint behaviorConfiguration="customQuotaBehavior" address="" binding="basicHttpBinding" bindingConfiguration="userServiceBasicHttp" contract="Contract.User.IUserManagementContract"></endpoint>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
客户端Web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IUserManagementContract" maxBufferPoolSize="2097152" maxReceivedMessageSize="2097152">
<readerQuotas maxDepth="999" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="customQuotaBehavior">
<dataContractSerializer maxItemsInObjectGraph="2097152"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint behaviorConfiguration="customQuotaBehavior" address="http://localhost:3479/UserManagementService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserManagementContract"
contract="UserManagementServiceReference.IUserManagementContract"
name="BasicHttpBinding_IUserManagementContract" />
</client>
</system.serviceModel>
Ajax Call
$.ajax({
type:"POST",
url: "http://localhost:2583/ApplicationManagement/SaveProfilePhoto",
data: { 'base64Photo': vData },
success: function (result) { alert(result); }
});
客户端方法
public string SaveProfilePhoto(string base64Photo)
{
UserManagementContractClient client = new UserManagementContractClient();
string userid = "someuserid";
//userid -- string
//PictureType --enum
//base64Photo --string
client.UpdateUserPhoto(userid, PictureType.UserPhoto,base64Photo);
return client.GetImage(userid, PictureType.UserPhoto);
}