2011-04-28 67 views
0

我有一個WCF服務的Silverlight應用程序訪問的SQL Server數據庫的表。我複製了教程中的所有代碼,並從桌面上運行它。它無法加載sql服務器數據,儘管一切正常加載。 其他職位談論http://localhost:PortNumber/Service1.svc是問題,我應該部署服務器,而其他人談論使用可觀察集合。有沒有人有解釋問題可能是什麼以及如何糾正它。Silverlight的DataGrid中不顯示數據

Imports System.ServiceModel 
Imports System.ServiceModel.Activation 

公共類服務

<OperationContract()> 
Public Function GetPostCounts() As List(Of RealTimePostCount) 
    ' Add your operation implementation here 
    Dim db As New DataClasses1DataContext 

    Dim posts = (From record In db.RealTimePostCounts Order By record.boxCount, record.boxFeed, record.pollDate Select record) 
    Dim list As New List(Of RealTimePostCount) 
    For Each p In posts 
     list.Add(New RealTimePostCount With {.boxCount = p.boxCount, .boxFeed = p.boxFeed, .pollDate = p.pollDate}) 
    Next 

    Return list 


End Function 

' Add more operations here and mark them with <OperationContract()> 

末級

servicerefernces..clientconfig

<configuration> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:12018/Service1.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1" 
      name="BasicHttpBinding_Service1" /> 
    </client> 
</system.serviceModel> 

回答

1

將問題分解成更小的塊。

  • 從等式中消除WCF以驗證您的Silverlight數據綁定是否正常工作。您可以通過簡單地綁定到預製列表來完成此操作。
  • WcfTestClient可以隔離和測試Web服務的獨立的Silverlight。
  • 當故障排除Silverlight和WCF在一起,fiddler是必須的,這樣你可以看到你的應用程序服務調用和響應。

希望這足以解決或引導您到一個更具體的問題。

+0

得到了與TestClient的以下錯誤:無法調用服務。可能的原因:服務處於脫機狀態或無法訪問;客戶端配置與代理不匹配;現有的代理無效。有關更多詳細信息,請參閱堆棧跟蹤。您可以嘗試通過啓動新代理,還原爲默認配置或刷新服務來進行恢復。 – vbNewbie 2011-04-28 22:12:32

+0

現在你有一個更詳細的錯誤。嘗試從這裏開始http://stackoverflow.com/questions/2671113/c-wcf-failed-to-invoke-the-service – agradl 2011-04-29 15:09:03

相關問題