首页 新闻 会员 周边 捐助

WCF 大数据传输 远程服务器返回了意外响应: (400) Bad Request。

0
悬赏园豆:20 [已解决问题] 解决于 2012-06-24 10:57

服务器配置文件:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="LargeDataTransferServicesBinding" maxBufferPoolSize="5242880000" maxReceivedMessageSize="655360000"  messageEncoding="Text" transferMode="Streamed" sendTimeout="00:10:00" />
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="DataService.SyncService">
        <endpoint address=""  bindingName="LargeDataTransferServicesBinding" binding="wsHttpBinding" contract="DataService.ISyncService" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>        
        <endpoint address="mex" bindingName="LargeDataTransferServicesBinding" binding="mexHttpBinding" contract="IMetadataExchange"  />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/DataService/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,
          请在部署前将以下值设置为 false 并删除上面的元数据终结点  -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- 要接收故障异常详细信息以进行调试,
          请将以下值设置为 true。在部署前设置为 false 
            以避免泄漏异常信息-->
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

客户端配置文件:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="LargeDataTransferServicesBinding_ISyncService"
          closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00"
          sendTimeout="00:03:00" bypassProxyOnLocal="false" transactionFlow="false"
          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="5242880000"
          maxReceivedMessageSize="655360000" messageEncoding="Text" textEncoding="utf-8"
          useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="655360000"
            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" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/DataService/Service1/"
        binding="wsHttpBinding" bindingConfiguration="LargeDataTransferServicesBinding_ISyncService"
        contract="ServiceReference1.ISyncService" name="LargeDataTransferServicesBinding_ISyncService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

异常图片:

IceS的主页 IceS | 初学一级 | 园豆:197
提问于:2012-06-24 09:46
< >
分享
最佳答案
0

在WCF服务端的web.config中增加如下设置,具体的错误会记录在.svclog文件中。

<system.diagnostics>
<sources>
    <source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">
    <listeners>
        <add name="xml" />
    </listeners>
    </source>
</sources>
<sharedListeners>
    <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="d:\temp\wcf.svclog" />
</sharedListeners>
</system.diagnostics>
收获园豆:15
dudu | 高人七级 |园豆:29568 | 2012-06-24 09:55
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131075</EventID><Type>3</Type><SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2012-06-24T02:03:54.6269520Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="WcfSvcHost" ProcessID="6584" ThreadID="9" /><Channel/><Computer>ICESPC</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"><TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier><Description>正在引发异常。</Description><AppDomain>E:\Project\X_信息管理系统\代码-信息管理系统\Sys_SyncInfoMangement\DataService\bin\Debug\DataService.dll.config</AppDomain><Exception><ExceptionType>System.ComponentModel.Win32Exception, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>指定的域不存在,或无法联系。</Message><StackTrace>   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromWindowsIdentity(WindowsIdentity windowsIdentity)
   在 System.ServiceModel.UpnEndpointIdentity.EnsureIdentityClaim()
   在 System.ServiceModel.Security.SecurityUtils.GetSpnFromIdentity(EndpointIdentity identity, EndpointAddress target)
   在 System.ServiceModel.Security.SspiNegotiationTokenAuthenticator.get_DefaultServiceBinding()
   在 System.ServiceModel.Security.SpnegoTokenAuthenticator.CreateSspiState(Byte[] incomingBlob, String incomingValueTypeUri)
   在 System.ServiceModel.Security.SspiNegotiationTokenAuthenticator.ProcessRequestSecurityToken(Message request, RequestSecurityToken requestSecurityToken, SspiNegotiationTokenAuthenticatorState&amp;amp; negotiationState)
   在 System.ServiceModel.Security.NegotiationTokenAuthenticator`1.ProcessRequestCore(Message request)
   在 System.ServiceModel.Security.NegotiationTokenAuthenticator`1.NegotiationHost.NegotiationSyncInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
   在 System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc)
   在 System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
   在 System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)
   在 System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
   在 System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
   在 System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
   在 System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   在 System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   在 System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
   在 System.Runtime.InputQueue`1.Dispatch()
   在 System.Runtime.InputQueue`1.OnDispatchCallback(Object state)
   在 System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   在 System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.ComponentModel.Win32Exception (0x80004005): 指定的域不存在,或无法联系。</ExceptionString><NativeErrorCode>54B</NativeErrorCode></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131076</EventID><Type>3</Type><SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2012-06-24T02:03:54.6425520Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="WcfSvcHost" ProcessID="6584" ThreadID="9" /><Channel/><Computer>ICESPC</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"><TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier><Description>正在处理异常。</Description><AppDomain>E:\Project\X_信息管理系统\代码-信息管理系统\Sys_SyncInfoMangement\DataService\bin\Debug\DataService.dll.config</AppDomain><Exception><ExceptionType>System.ComponentModel.Win32Exception, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>指定的域不存在,或无法联系。</Message><StackTrace>   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromWindowsIdentity(WindowsIdentity windowsIdentity)</StackTrace><ExceptionString>System.ComponentModel.Win32Exception (0x80004005): 指定的域不存在,或无法联系。
   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
   在 System.ServiceModel.UpnEndpointIdentity.GetUpnFromWindowsIdentity(WindowsIdentity windowsIdentity)</ExceptionString><NativeErrorCode>54B</NativeErrorCode></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131075</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2012-06-24T02:03:57.8661566Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="WcfSvcHost" ProcessID="6584" ThreadID="9" /><Channel/><Computer>ICESPC</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"><TraceIdentifier>http://msdn.microsoft.com/zh-CN/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier><Description>正在引发异常。</Description><AppDomain>E:\Project\X_信息管理系统\代码-信息管理系统\Sys_SyncInfoMangement\DataService\bin\Debug\DataService.dll.config</AppDomain><Exception><ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。</Message><StackTrace>   在 System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
   在 System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
   在 System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
   在 System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
   在 System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&amp;amp; requestException)
   在 System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
   在 System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
   在 System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult result)
   在 System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result)
   在 System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   在 System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.ServiceModel.ProtocolException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。</ExceptionString><DataItems><Data><Key>System.ServiceModel.Channels.HttpInput.HttpStatusCode</Key><Value>BadRequest</Value></Data></DataItems></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>

<ExceptionString>System.ServiceModel.ProtocolException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。

在上面的配置文件中我已经设置了。。。。为什么还是65536

IceS | 园豆:197 (初学一级) | 2012-06-24 10:07
其他回答(1)
0

我以前也遇到过这样的问题(我的错误原因是:数据类型不支持)。你的客户端发回的数据类型是什么?

收获园豆:5
Angkor--:-- | 园豆:1086 (小虾三级) | 2012-06-24 10:19

varchar ;uniqueidentifier;

支持(0) 反对(0) IceS | 园豆:197 (初学一级) | 2012-06-24 10:24

@IceS: 你这个是数据库中定义的列的数据类型吧,我是说你的方法返回值类型?

支持(0) 反对(0) Angkor--:-- | 园豆:1086 (小虾三级) | 2012-06-24 10:34

问题找到了,配置文件中<binging>节点放错组了

支持(0) 反对(0) IceS | 园豆:197 (初学一级) | 2012-06-24 10:59

@IceS: 仔细,小心,别犯这样低级的错误哦!!!

支持(0) 反对(0) Angkor--:-- | 园豆:1086 (小虾三级) | 2012-06-24 11:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册