2009-08-25 30 views
8

Tôi đang gọi Dịch vụ web WCF cục bộ (hoặc từ xa) hoạt động tốt với một lượng nhỏ dữ liệu (khoảng 25 dòng < 1K dữ liệu ea). Nhưng khi dữ liệu trở nên lớn hơn (khoảng 300 dòng) thì dịch vụ web không thành công. Dưới đây là Ngoại lệ, Ngoại lệ bên trong và Dấu vết ngăn xếp từ Ngoại lệ bên trong.Dịch vụ web WCF không nhận được dữ liệu lớn

Dịch vụ này cũng có vẻ mất nhiều thời gian để thực thi cục bộ (tôi thêm điều này vì nó có thể cung cấp cho bạn một số gợi ý trong việc giải quyết). Lấy số lượng lớn dữ liệu mất 3s phía máy chủ và nhỏ về dữ liệu mất 1s phía máy chủ. Tuy nhiên, chạy dịch vụ web (cục bộ) để lấy lại một lượng nhỏ dữ liệu mất 24 giây.

Tôi cũng có bao gồm thông tin ràng buộc từ app.config từ ứng dụng thử nghiệm ứng dụng khách của tôi.

========= RÀNG BUỘC THÔNG TIN ===========

<system.serviceModel> 
    <bindings> 
    <basicHttpBinding> 
     <binding name="BasicHttpBinding_IFormsService" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="02:00:00" sendTimeout="00:02:00" 
      allowCookies="false" bypassProxyOnLocal="false" 
      hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
      maxReceivedMessageSize="2147483647" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="1000000000" 
         maxArrayLength="1000000000" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"> 
      <transport clientCredentialType="None" 
         proxyCredentialType="None" realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<client> 
    <endpoint 
     address="http://monica-pc/TrialIQSvc/FormsService.svc/FormsService/FormsService.Svc" 
     binding="basicHttpBinding" 
     bindingConfiguration="BasicHttpBinding_IFormsService" 
     contract="WebService.IFormsService" name="BasicHttpBinding_IFormsService" /> 
</client> 

EXCEPTION ========= DATA =============

**Exception**: An error occurred while receiving the HTTP response to http://monica-pc/TrialIQSvc/FormsService.svc/FormsService/FormsService.Svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. 

**Inner Exception**: The underlying connection was closed: An unexpected error occurred on a receive. 
    **Stack trace**: 
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 Test.WebService.IFormsService.GetFormGroupInstance(String formGroupId, String subjectId, String userId) 
    at Test.WebService.FormsServiceClient.GetFormGroupInstance(String formGroupId, String subjectId, String userId) in G:\SVNTrialIQ\trunk\Common\trunk\source\Forms\Test\Service References\WebService\Reference.cs:line 59 
    at Test.Form1.btnInstanceInfo_Click(Object sender, EventArgs e) in G:\SVNTrialIQ\trunk\Common\trunk\source\Forms\Test\Form1.cs:line 408 

Trả lời

2

Để nhận thông tin lỗi mở rộng, hãy thử sử dụng SvcTraceViewer.

+0

Yup! Điều đó đã làm điều đó. Tôi không thể nhận được một dấu vết để xuất hiện trên máy tính của tôi (Vista). Nhưng, khi tôi nhìn vào giao diện IIS 7 được cung cấp với Vista, tôi phải thừa nhận nó làm cho tôi cảm thấy như tôi chưa bao giờ chạm vào một máy tính trước đây trong cuộc sống của tôi. Vì vậy, tôi đã không làm quá nhiều xử lý sự cố. –

+0

Tuy nhiên, chạy mã theo dõi trong web.config trên máy chủ Win2003 của tôi tiết lộ đó là lỗi Loại do kế thừa, điều này khá không liên quan, nhưng được mô tả độc đáo ở đây: http://developers.de/blogs/damir_dobric/archive /2009/03/24/about-quot-knowntypeattribute-quot-example.aspx –

0

Có thể bạn đang thiếu một số cấu hình ở phía máy chủ

2

Có một số điều có thể xảy ra.

Trước hết, như "darin" đã được đề xuất - hãy thử bật tính năng theo dõi thông báo và xem nội dung tạo ra.

Thứ hai - bạn có thể sắp hết thời gian chờ. Bạn nói rằng tập dữ liệu nhỏ của bạn mất khoảng 24 giây để quay lại, tập dữ liệu lớn hơn của bạn lớn gấp 12 lần (300 so với 25 dòng), vì vậy có thể mất 288 giây - nhưng sendTimeout của bạn được đặt thành 2 phút - để có thể nguyên nhân. Hãy thử tăng rằng cài đặt để giả sử 10 phút - đó nên thời gian dư dật:

<binding name="BasicHttpBinding_IFormsService" 
      sendTimeout="00:10:00" 

Nếu điều đó không giải quyết nó - bạn có thể thử sử dụng trực tuyến để di chuyển phía sau một lượng lớn dữ liệu:

<binding name="BasicHttpBinding_IFormsService" 
     transferMode="StreamedResponse"> 

Miễn là chỉ có câu trả lời của bạn lớn, điều đó sẽ hiệu quả. Tất nhiên, bạn phải rearchitect khách hàng của bạn gọi dịch vụ một chút để xử lý streaming (tạo một hợp đồng hoạt động = phương thức dịch vụ trả về giá trị trả về Stream và sử dụng luồng để đọc dữ liệu theo khối từ máy chủ) . Nếu đó là một tình huống phổ biến đối với bạn, điều đó có thể làm việc và có giá trị nỗ lực (và nó sẽ cho phép bạn giảm kích thước bộ đệm của bạn một lần nữa, để tránh một cuộc tấn công từ chối dịch vụ bằng cách tràn ngập các thông điệp lớn).

Xem số intro to WCF message streaming tuyệt vời để biết thêm thông tin về phát trực tuyến.

Và nếu không có gì hữu ích - hãy quay lại và cho chúng tôi biết!

Marc

+0

Tôi xem bài viết trực tuyến. Tham khảo tuyệt vời! Điều chỉnh hiệu suất là bước tiếp theo của tôi. –

0

Hãy thử điều này: trong phần hệ thống.web. Đặt thuộc tính maxRequestLength.

<httpRuntime executionTimeout="90" maxRequestLength="1048576" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/> 
0

Lỗi này có thể do không khớp hợp đồng. Xem xét ba ứng dụng xếp lớp bên dưới ...

UI Layer        
    |  
Process Layer 
    | 
Data Access Layer     
-> Contract Between Process and UI layer has the same enum with missing (Onhold = 3). Enum: Start = 1, Stop = 2. 
-> Contract Between Data Access And Process layer has enum Enum: Start = 1,Stop = 2,Onhold = 3. 

Trong trường hợp này, chúng tôi sẽ gặp lỗi tương tự trong phản hồi lớp quy trình.

Lỗi tương tự xuất hiện trong sự không khớp hợp đồng khác trong ứng dụng nhiều lớp.

Các vấn đề liên quan