远程服务器返回了意外的响应:(400)错误的请求 [英] The remote server returned an unexpected response: (400) Bad Request

查看:137
本文介绍了远程服务器返回了意外的响应:(400)错误的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个问题,无法通过WCF服务发送大量数据.我发现错误远程服务器返回了意外的响应:(400)错误的请求"
请任何人发送需要的帮助.

我的服务器端代码:

< system.servicemodel>
< bindings>
< wshttpbinding>
<!-< binding name ="WSHttpBinding_IService1" closetimeout ="00:01:00">
openTimeout ="00:01:00" receiveTimeout ="00:10:00" sendTimeout ="00:01:00"
绕过ProxyProxyOnLocal ="false" transactionFlow ="false" hostNameComparisonMode ="StrongWildcard"
maxBufferPoolSize ="524288" maxReceivedMessageSize ="65536" messageEncoding =文本"
textEncoding ="utf-8" useDefaultWebProxy ="true" allowCookies ="false">
< readerquotas maxdepth ="32" maxstringcontentlength ="8192" maxarraylength ="16384">
maxBytesPerRead ="4096" maxNameTableCharCount ="16384"/>->


< binding name ="WSHttpBinding_IService1" closetimeout ="00:10:00">
openTimeout ="00:10:00" receiveTimeout ="00:10:00" sendTimeout ="00:10:00"
绕过ProxyProxyOnLocal ="false" transactionFlow ="false" hostNameComparisonMode ="StrongWildcard"
maxBufferPoolSize ="2147483647" maxReceivedMessageSize ="2147483647"
messageEncoding =文本" textEncoding ="utf-8" useDefaultWebProxy ="true"
allowCookies ="false">
< readerquotas maxdepth ="2147483647" maxstringcontentlength ="2147483647" maxarraylength ="2147483647">
maxBytesPerRead ="2147483647" maxNameTableCharCount ="2147483647"/>



< services>
< service name ="WcfService.Service1" behaviorconfiguration ="WcfService.Service1Behavior">
<!-服务端点->
< endpoint address =" binding ="wsHttpBinding" contract ="WcfService.IService1">
<!-
部署后,应删除或替换以下标识元素,以反映
运行已部署服务的身份.如果删除,WCF将推断出适当的身份
自动.
->
< identity>
< dns value ="localhost">


< endpoint address ="mex" binding ="mexHttpBinding" contract ="IMetadataExchange">


<行为>
< servicebehaviors>
< behavior name ="WcfService.Service1Behavior">
<!-为避免泄露元数据信息,请在部署之前将下面的值设置为false并删除上面的元数据终结点->
< servicemetadata httpgetenabled ="true">
<!-要在故障中接收异常详细信息以进行调试,请将下面的值设置为true.部署前设置为false以避免泄露异常信息->
< servicedebug includeexceptiondetailinfaults ="false">






< system.webserver>
< modules runallmanagedmodulesforallrequests ="true">




客户端代码:

< system.servicemodel>

< bindings>
< wshttpbinding>
< binding name ="WSHttpBinding_IService1" closetimeout ="00:01:00">
openTimeout ="00:01:00" receiveTimeout ="00:10:00" sendTimeout ="00:01:00"
绕过ProxyProxyOnLocal ="false" transactionFlow ="false" hostNameComparisonMode ="StrongWildcard"
maxBufferPoolSize ="524288" maxReceivedMessageSize ="65536" messageEncoding =文本"
textEncoding ="utf-8" useDefaultWebProxy ="true" allowCookies ="false">
< readerquotas maxdepth ="32" maxstringcontentlength ="8192" maxarraylength ="16384">
maxBytesPerRead ="4096" maxNameTableCharCount ="16384"/>
< reliablesessionordered ="true" inactivitytimeout ="00:10:00">
enabled ="false"/>
<安全模式=消息">
< transport clientcredentialtype ="Windows" proxycredentialtype ="None"> realm ="/>
< message clientcredentialtype ="Windows" negotiationservicecredential ="true">
algorithmSuite =默认"/>




< client>
<端点地址="http://localhost:51470/Service1.svc" binding ="wsHttpBinding">
bindingConfiguration ="WSHttpBinding_IService1" contract ="ServiceRefe_WCF.IService1"
name ="WSHttpBinding_IService1">
< identity>
< dns value ="localhost">



<行为>
< servicebehaviors>
<行为>
<!-为避免泄露元数据信息,请在部署之前将下面的值设置为false并删除上面的元数据终结点->
< servicemetadata httpgetenabled ="true">
<!-要在故障中接收异常详细信息以进行调试,请将下面的值设置为true.部署前设置为false以避免泄露异常信息->
< servicedebug includeexceptiondetailinfaults ="false">



< servicehostingenvironment Multiplesitebindingsenabled ="true">


谢谢&问候
Ram Kumar

Hi All,


I have a problem to send large amount of data by WCF service.I found a error "The remote server returned an unexpected response: (400) Bad Request"
please anyone send a needful help.

My server side code:

<system.servicemodel>
<bindings>
<wshttpbinding>
<!--<binding name="WSHttpBinding_IService1" closetimeout="00:01:00">
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />-->


<binding name="WSHttpBinding_IService1" closetimeout="00:10:00">
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647">
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />



<services>
<service name="WcfService.Service1" behaviorconfiguration="WcfService.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="WcfService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost">


<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">


<behaviors>
<servicebehaviors>
<behavior name="WcfService.Service1Behavior">
<!-- 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">






<system.webserver>
<modules runallmanagedmodulesforallrequests="true">




Client Side Code:

<system.servicemodel>

<bindings>
<wshttpbinding>
<binding name="WSHttpBinding_IService1" closetimeout="00:01:00">
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliablesession ordered="true" inactivitytimeout="00:10:00">
enabled="false" />
<security mode="Message">
<transport clientcredentialtype="Windows" proxycredentialtype="None"> realm="" />
<message clientcredentialtype="Windows" negotiateservicecredential="true">
algorithmSuite="Default" />




<client>
<endpoint address="http://localhost:51470/Service1.svc" binding="wsHttpBinding">
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceRefe_WCF.IService1"
name="WSHttpBinding_IService1">
<identity>
<dns value="localhost">



<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">



<servicehostingenvironment multiplesitebindingsenabled="true">


Thanks & Regards
Ram Kumar

推荐答案

这是人们反复使用WCF时经常遇到的问题.

我认为您缺少的是maxItemsInObjectGraph.但是下面的文章讨论了对具有大量数据的WCF请求的更广泛的配置要求.


http://stackoverflow.com/questions/8225736/transfer-large- wcf-service中的数据量 [ ^ ]
This is a recurring problem with people getting to grips with WCF.

The bit I think you''re missing is maxItemsInObjectGraph. But the following article discusses the wider configuration requirements for WCF requests with large amounts of data.


http://stackoverflow.com/questions/8225736/transfer-large-amount-of-data-in-wcf-service[^]


我找到了Bad Request 400问题的答案.

这是默认的服务器绑定设置.您需要将其添加到服务器和客户端的默认设置.

绑定名称=" openTimeout ="00:10:00" closeTimeout ="00:10:00" receiveTimeout ="00:10:00" sendTimeout ="00:10:00" maxReceivedMessageSize ="2147483647" maxBufferPoolSize ="2147483647 "maxBufferSize =" 2147483647>
I found the answer to the Bad Request 400 problem.

It was the default server binding setting. You would need to add to server and client default setting.

binding name="" openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">


这篇关于远程服务器返回了意外的响应:(400)错误的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆