2011-02-02 71 views
0

我不知道爲什麼我在我的代碼recieving一個TimeoutException:超時異常在WCF回調

Dim Uri2 As New Uri("http://localhost:8733/Design_Time_Addresses/ssWcfService/Service1/") 
    Dim binding2 As New WSDualHttpBinding() 

    Dim callback = New MyCallBackClient() 

    Dim Client = New MyContractClient(callback, binding2, New EndpointAddress(Uri2)) 

    'Dim Proxy = Client.ChannelFactory.CreateChannel() 
    Dim ProxyNotFaulty = Client.ChannelFactory.CreateChannel() 

    Try 
     Dim dataList As New List(Of DataClass) 
     Dim datas As New DataClass 

     RichTextBox.Text = "Connecting to WCF Service..." 
     RichTextBox.Text += Environment.NewLine + "Please Wait..." 

     RichTextBox.Text += Environment.NewLine + "Please Wait..." 
     RichTextBox.Text += Environment.NewLine + "The Operation is now Invoking..." 

     ProxyNotFaulty.DoSomething() 

     For Each Clientdata As DataClass In dataList 
      RichTextBox.Text += "The CallBack Status" + Clientdata.callbackMessage 
      RichTextBox.Text += Environment.NewLine 
      RichTextBox.Text += "After CallBack Status" + Clientdata.OnCallBackMessage 
     Next Clientdata 
     Client.Close() 
    Catch ex As Exception 
     MessageBox.Show("An Exception Happened:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) 
     Client.Abort() 
    Finally 
    End Try 

Sub DoSomething() Implements IService1.DoSomething 
    data.callbackMessage = "Call Back is Made SuccessFully From Client To Service" 
    data.OnCallBackMessage = "Null" 
    dataList.Add(data) 
    Dim callBack = OperationContext.Current.GetCallbackChannel(Of IIIService1)() 
    callBack.OnCallBack() 
End Sub 

Public Interface IService1 

    <OperationContract()> 
    Sub DoSomething() 

    <OperationContract()> 
    Sub DoSomethingTwo() 

    <OperationContract()> 
    Function GetStatus() As List(Of DataClass) 


    '<OperationContract()> 
    'Function GetData(ByVal value As Integer) As String 

    '<OperationContract()> 
    'Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType 

    ' TODO: Add your service operations here 

End Interface 

Public Interface IIIService1 

    <OperationContract(IsOneWay:=True)> 
    Sub OnCallBack() 

    <OperationContract(IsOneWay:=True)> 
    Sub OnCallBackFromService() 


End Interface 
+0

爲什麼你創建ProxyNotFaulty頻道,如果您有客戶對象?什麼方法確實導致異常? – vorrtex 2011-02-02 17:01:46

回答

0

是它達到你的服務?你有沒有使用Fiddler來了解通信方面的情況?使用Visual Studio附加到您的服務(自己託管)或附加到IIS(在IIS下託管)並在入口點上設置一個斷點並查看那裏正在發生的事情。

這有可能是

  1. 它沒有得到你的服務
  2. 您服務的時間過長,並且超時