Передайте больший файл, используя сервис WCF с basichttpbinding - PullRequest
1 голос
/ 16 марта 2012

Ошибка ниже, когда я пытаюсь передать более 150 МБ файлов.

System.ServiceModel.CommunicationException was unhandled
  Message="An error occurred while making the HTTP request to http://localhost:2122/Service1.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."
  Source="mscorlib"
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Cleint.ServiceReference1.IService1.UploadFile(RemoteFileInfo request)
       at Cleint.ServiceReference1.Service1Client.Cleint.ServiceReference1.IService1.UploadFile(RemoteFileInfo request) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Service References\ServiceReference1\Reference.cs:line 81
       at Cleint.ServiceReference1.Service1Client.UploadFile(String fileName, Stream fileByteStream) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Service References\ServiceReference1\Reference.cs:line 88
       at Cleint.Program.Main(String[] args) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Program.cs:line 20
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       Message="The underlying connection was closed: An unexpected error occurred on a send."
       Source="System"
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       InnerException: System.IO.IOException
            Message="Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."
            Source="System"
            StackTrace:
                 at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
                 at System.Net.Connection.Write(ScatterGatherBuffers writeBuffer)
                 at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream, Boolean suppressWrite)
            InnerException: System.Net.Sockets.SocketException
                 Message="An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"
                 Source="System"
                 ErrorCode=10055
                 NativeErrorCode=10055
                 StackTrace:
                      at System.Net.Sockets.Socket.MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags)
                      at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
                 InnerException: 

Ответы [ 2 ]

1 голос
/ 16 марта 2012

По умолчанию transferMode - это буфер , поэтому большие сообщения помещаются в буфер. Если у вас есть доступ для изменения пункта назначения службы (кода), я рекомендую использовать режим передачи Потоковая или MTOM кодировка сообщений для обмена такими большими сообщениями / файлами.

0 голосов
/ 16 марта 2012

Почему вы пытаетесь передать 150 МБ через границу веб-службы? Такой дизайн почти наверняка вызовет проблемы с доступностью конечной точки службы.

Лучшим вариантом было бы записать файл на диск куда-нибудь, а затем отправить командное сообщение службе, чтобы забрать файл.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...