Asp.net 在wcf服务中将bmp文件/图像作为参数传递
我正在尝试在WCF服务中将BMP文件作为参数传递。当BMP文件的大小为350kb时,我收到一个错误。当我传递一个10-20KB的小文件时,它运行得非常好Asp.net 在wcf服务中将bmp文件/图像作为参数传递,asp.net,wcf,Asp.net,Wcf,我正在尝试在WCF服务中将BMP文件作为参数传递。当BMP文件的大小为350kb时,我收到一个错误。当我传递一个10-20KB的小文件时,它运行得非常好 The remote server returned an unexpected response: (413) Request Entity Too Large. [OperationContract] byte[] ConvertData(Bitmap bmp); 我尝试通过以下链接更改IIS设置来解决此问题:但运气不好 我的服务器w
The remote server returned an unexpected response: (413) Request Entity Too Large.
[OperationContract]
byte[] ConvertData(Bitmap bmp);
我尝试通过以下链接更改IIS设置来解决此问题:但运气不好
我的服务器web.config是
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
我的客户端Web.Config是
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240000"/>
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ReDrawImgService.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="ReDrawImgService.IService1"/>
</service>
</services>
<client>
<endpoint address="http://localhost:8012/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceClient.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
在您的readerQuotas上,尝试将maxStringContentLength设置为2147483647,并确保此配置设置为两端 因此,服务器和客户端都需要这些值。如果客户端被允许发送一个大文件,或者服务器无论如何都会拒绝它,那就没有帮助了
在您的readerQuotas上,wcf服务器应用程序上的
maxArrayLength
的值是多少?请尝试将maxStringContentLength设置为2147483647,并确保此配置设置为两端
因此,服务器和客户端都需要这些值。如果客户端被允许发送一个大文件,或者服务器无论如何都会拒绝它,那就没有帮助了
wcf服务器应用程序上的
maxArrayLength
的值是多少?您好,谢谢您的回复,我在两个配置中将maxStringContentLength更改为2147483647,但仍会收到相同的错误并且调试此配置时,服务器和客户端上的maxArrayLength都相同,你能得到比你的帖子里更多的细节吗。通常当这失败时,异常会指向错误的地方,例如,内容比maxStringContentLength长。例如,我传递了一个bmp文件作为参数,bmp文件的大小是350 kb,当我传递一个10-20 kb的小文件时,它运行得很好,但在350 kb的文件上出现错误我也有一个发送文件的服务(最多2-3 MB)我在两端设置了以下值:maxArrayLength、maxStringContentLength、maxReceivedMessageSize。我也将MaxDepth设置为128,但我认为这与图像发送无关。您设置了一些值,但我没有。也许您应该尝试删除它们?这些是httpRuntime的MaxRequestLength、maxBytesPerRead、maxNameTableCharCount、 maxBufferPoolSize。记住两端;)嗨,我已经从服务器和客户端配置中删除了它们,但仍然出现相同的错误:(是否与iis有关,能否将图像服务的示例项目发送给我,我已经更新了相关的web.config。您好,谢谢您的回复。我已将两个配置中的maxStringContentLength更改为2147483647,但仍然会收到相同的错误
,并且当您取消配置时,服务器和客户端上的maxArrayLength都相同对此,您是否得到了比您的帖子中给出的更多的详细信息。通常,当此操作失败时,异常将指向错误所在,例如,内容长度超过maxStringContentLength。例如,我已将bmp文件作为参数传递,当我传递一个10-20 kb的小文件时,bmp文件的大小为350 kb。它运行正常,but在350 kb文件上给出错误我有一个发送文件的服务(最多2-3 MB)我在两端设置了以下值:maxArrayLength、maxStringContentLength、maxReceivedMessageSize。我也将MaxDepth设置为128,但我认为这与图像发送无关。您设置了一些值,但我没有。也许您应该尝试删除它们?这些是httpRuntime的MaxRequestLength、maxBytesPerRead、maxNameTableCharCount、 maxBufferPoolSize.两端都记得;)嗨,我已经从我的服务器和客户端配置中删除了它们,但给出了相同的错误:(是否与iis有关,您能给我发送映像服务的示例项目吗,我也更新了相关的web.config