WCF, ServiceStack, .NET Remoting etc. on Windows Phone

  • VB.NET

    WCF, ServiceStack, .NET Remoting etc. on Windows Phone

    Hallihallo liebe vb-paradise-Gemeine!

    Ich stehe vor einem Problem:

    Mein Windows Phone gibt mir immer die folgende Nachricht zurück wenn ich versuche irgendwie auf meinen PC zu kommen:

    Spoiler anzeigen

    Quellcode

    1. {System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
    2. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
    3. at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
    4. at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
    5. --- End of inner exception stack trace ---
    6. at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
    7. at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    8. at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
    9. --- End of inner exception stack trace ---
    10. at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
    11. at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
    12. at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
    13. at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.HelloWorldSoapClientChannel.EndGetHello(IAsyncResult result)
    14. at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.ServiceStackHWWPClient.HelloWorld.HelloWorldSoap.EndGetHello(IAsyncResult result)
    15. at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.EndGetHello(IAsyncResult result)
    16. at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.OnEndGetHello(IAsyncResult result)
    17. at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
    18. InnerException:
    19. {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
    20. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
    21. at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
    22. at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
    23. --- End of inner exception stack trace ---
    24. at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
    25. at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    26. at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}


    Mein Code ist der folgende vom Server (FMSServer.svc.vb):

    Spoiler anzeigen

    VB.NET-Quellcode

    1. ' HINWEIS: Mit dem Befehl "Umbenennen" im Kontextmenü können Sie den Klassennamen "Service1" sowohl im Code als auch in der SVC-Datei und der Konfigurationsdatei ändern.
    2. ' HINWEIS: Wählen Sie zum Starten des WCF-Testclients zum Testen dieses Diensts Service1.svc oder Service1.svc.vb im Projektmappen-Explorer aus, und starten Sie das Debuggen.
    3. Public Class FMSServer
    4. Implements IFMSServer
    5. Friend Shared Profiles As New System.Collections.Generic.Dictionary(Of String, Profile)
    6. Private Shared Keys As New System.Collections.Generic.Dictionary(Of String, String)
    7. Friend Shared Familys As New System.Collections.Generic.Dictionary(Of String, Family)
    8. Friend Shared ChatRooms As New System.Collections.Generic.Dictionary(Of String, ChatRoom)
    9. Private Shared Initializeda As Boolean = False
    10. Public Sub Initialize()
    11. If Initializeda Then
    12. Return
    13. End If
    14. Initializeda = True
    15. Dim f As New Family()
    16. Dim p1 As New Profile()
    17. Dim p2 As New Profile()
    18. Dim p3 As New Profile()
    19. Dim p4 As New Profile()
    20. Dim p5 As New Profile()
    21. Dim admin As New Profile()
    22. f.Family_ID = "std"
    23. p1.ID = "aaa"
    24. p2.ID = "bbb"
    25. p3.ID = "ccc"
    26. p4.ID = "ddd"
    27. p5.ID = "eee"
    28. admin.ID = "fff"
    29. Dim fc As New ChatRoom(False, f, New System.Collections.Generic.List(Of String)({p1.ID, p2.ID, p3.ID, p4.ID, p5.ID}), "3A574B82-8C4C-45F5-B882-8DC8E2A87205", "FamilyChat Heuwes")
    30. Dim c12 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p2.ID}), "43CDC115-5C46-4493-A4D2-57290843EC04")
    31. Dim c13 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p3.ID}), "4FAF572F-84AA-40D7-B703-493D4F5FFC07")
    32. Dim c14 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p4.ID}), "44415ED7-4C3B-4400-8423-12A1EF90E9BF")
    33. Dim c15 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p5.ID}), "204EC6F3-AEED-4F87-98F6-6FF5548C9AF2")
    34. Dim c23 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p3.ID}), "AD6C3DC7-E3ED-4D7D-A3F7-21ECB89D0397")
    35. Dim c24 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p4.ID}), "FEE15387-5224-49A4-958D-EB1F9E1E9D26")
    36. Dim c25 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p5.ID}), "AF58B405-58A2-443E-ACAC-AD09898A60E7")
    37. Dim c34 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p3.ID, p4.ID}), "E2EA4056-116A-4BAD-AFC2-823E651DAF1F")
    38. Dim c35 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p3.ID, p5.ID}), "1D14FEA3-AEAD-471B-8FBD-FF6815285562")
    39. Dim c45 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p4.ID, p5.ID}), "0B0B8621-E0B9-41FE-9E86-17EA13610213")
    40. f.Family_Name = "std"
    41. f.FamilyMembers.Add(p1)
    42. f.FamilyMembers.Add(p2)
    43. f.FamilyMembers.Add(p3)
    44. f.FamilyMembers.Add(p4)
    45. f.FamilyMembers.Add(p5)
    46. p1.Name = "std"
    47. p1.Family = f.Family_ID
    48. p1.ChatRooms.AddRange({c12.ID, c13.ID, c14.ID, c15.ID, fc.ID})
    49. p2.Name = "std"
    50. p2.Family = f.Family_ID
    51. p2.ChatRooms.AddRange({c12.ID, c23.ID, c24.ID, c25.ID, fc.ID})
    52. p3.Name = "std"
    53. p3.Family = f.Family_ID
    54. p3.ChatRooms.AddRange({c13.ID, c23.ID, c34.ID, c35.ID, fc.ID})
    55. p4.Name = "std"
    56. p4.Family = f.Family_ID
    57. p4.ChatRooms.AddRange({c14.ID, c24.ID, c34.ID, c45.ID, fc.ID})
    58. p5.Name = "std"
    59. p5.Family = f.Family_ID
    60. p5.ChatRooms.AddRange({c15.ID, c25.ID, c35.ID, c45.ID, fc.ID})
    61. Profiles.Add(p1.ID, p1)
    62. Profiles.Add(p2.ID, p2)
    63. Profiles.Add(p3.ID, p3)
    64. Profiles.Add(p4.ID, p4)
    65. Profiles.Add(p5.ID, p5)
    66. Familys.Add(f.family_ID, f)
    67. ' Passwort immer mit 35 Zeichen
    68. Keys.Add("aaa", "aaa") ' Verschleiert
    69. Keys.Add("bbb", "bbb")
    70. Keys.Add("ccc", ccc")
    71. Keys.Add("ddd", "ddd")
    72. Keys.Add("eee", "eee")
    73. Keys.Add("fff", "fff")
    74. ChatRooms.Add(c12.ID, c12)
    75. ChatRooms.Add(c13.ID, c13)
    76. ChatRooms.Add(c14.ID, c14)
    77. ChatRooms.Add(c15.ID, c15)
    78. ChatRooms.Add(c23.ID, c23)
    79. ChatRooms.Add(c24.ID, c24)
    80. ChatRooms.Add(c25.ID, c25)
    81. ChatRooms.Add(c34.ID, c34)
    82. ChatRooms.Add(c35.ID, c35)
    83. ChatRooms.Add(c45.ID, c45)
    84. ChatRooms.Add(fc.ID, fc)
    85. End Sub
    86. Public Function GetProfile(ByVal ProfileID As String, ByVal key As String) As Profile Implements IFMSServer.GetProfile
    87. Initialize()
    88. If key <> Keys(ProfileID) Then
    89. Return Nothing
    90. End If
    91. Dim p As Profile = Profiles(ProfileID)
    92. Return p
    93. End Function
    94. Public Function GetOtherProfile(ByVal ProfileID As String, ByVal key As String, ByVal TargetProfileID As String) As Profile Implements IFMSServer.GetOtherProfile
    95. Initialize()
    96. If key <> Keys(ProfileID) Then
    97. Return Nothing
    98. End If
    99. Dim p As Profile = Profiles(TargetProfileID)
    100. If Not p.Family = Profiles(ProfileID).Family Then
    101. Return Nothing
    102. End If
    103. Return p
    104. End Function
    105. Public Function GetFamily(ByVal FamilyID As String, ByVal ProfileID As String, ByVal key As String) As Family Implements IFMSServer.GetFamily
    106. Initialize()
    107. If key <> Keys(ProfileID) Then
    108. Return Nothing
    109. End If
    110. If FamilyID = "" Then
    111. Return Familys(Profiles(ProfileID).Family)
    112. End If
    113. If Profiles(ProfileID).Family <> FamilyID Then
    114. Return Nothing
    115. End If
    116. Return Familys(FamilyID)
    117. End Function
    118. Public Function GetChats(ByVal ProfileID As String, ByVal key As String) As System.Collections.Generic.List(Of ChatRoom) Implements IFMSServer.GetChats
    119. Initialize()
    120. If key <> Keys(ProfileID) Then
    121. Return Nothing
    122. End If
    123. Return Profiles(ProfileID).GetChatRoomList
    124. End Function
    125. Public Function CheckNewMessage(ByVal ProfileID As String, ByVal Key As String) As Boolean Implements IFMSServer.CheckNewMessage
    126. Initialize()
    127. If Key <> Keys(ProfileID) Then
    128. Return Nothing
    129. End If
    130. Return GetProfile(ProfileID, Key).IsNewMessageAvailable
    131. End Function
    132. Public Function SendMessage(ByVal ProfileID As String, ByVal Key As String, ByVal Message As String, ByVal ChatRoomID As String) As Boolean Implements IFMSServer.SendMessage
    133. Initialize()
    134. If Key <> Keys(ProfileID) Then
    135. Return False
    136. End If
    137. Dim a As Boolean
    138. For Each c As String In Profiles(ProfileID).ChatRooms
    139. If c = ChatRoomID Then
    140. a = True
    141. End If
    142. Next
    143. If Not a Then
    144. Return Nothing
    145. End If
    146. Dim cr1 As ChatRoom
    147. For Each cr As ChatRoom In GetProfile(ProfileID, Key).GetChatRoomList()
    148. If cr.ID = ChatRoomID Then
    149. cr1 = cr
    150. GoTo HaveAGoodDay
    151. End If
    152. Next
    153. Return False
    154. HaveAGoodDay: Dim m As New Message() With {.From = ProfileID, .Message = Message}
    155. cr1.Messages.Add(m)
    156. For Each p As Profile In cr1.GetWithPsList
    157. p.IsNewMessageAvailable = True
    158. m.IsNew.Add(p.ID, True)
    159. Next
    160. Return True
    161. End Function
    162. Public Function GetNewMessages(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.List(Of Message) Implements IFMSServer.GetNewMessages
    163. Initialize()
    164. If Key <> Keys(ProfileID) Then
    165. Return Nothing
    166. End If
    167. Dim EMA As New System.Collections.Generic.List(Of Message)
    168. For Each CR As ChatRoom In GetProfile(ProfileID, Key).GetChatRoomList
    169. For Each M As Message In CR.Messages
    170. If M.IsNew(ProfileID) Then
    171. M.IsNew(ProfileID) = False
    172. EMA.Add(M)
    173. Profiles(ProfileID).IsNewMessageAvailable = False
    174. End If
    175. Next
    176. Next
    177. Return EMA
    178. End Function
    179. Public Function CheckNewState(ProfileID As String, Key As String) As Boolean Implements IFMSServer.CheckNewState
    180. Initialize()
    181. If Key <> Keys(ProfileID) Then
    182. Return Nothing
    183. End If
    184. For Each d As System.Collections.Generic.KeyValuePair(Of String, String) In Profiles(ProfileID).States
    185. If Profiles(d.Key).State = d.Value Then
    186. Return True
    187. End If
    188. Next
    189. Return False
    190. End Function
    191. Public Function GetNewState(ProfileID As String, Key As String) As Dictionary(Of String, String) Implements IFMSServer.GetNewState
    192. Initialize()
    193. Dim a As New Dictionary(Of String, String)
    194. For Each s As Generic.KeyValuePair(Of String, String) In Profiles(ProfileID).States
    195. If s.Value <> Profiles(s.Key).State Then
    196. a.Add(s.Key, Profiles(s.Key).State)
    197. End If
    198. Next
    199. Return a
    200. End Function
    201. Public Function GetState(OwnProfileID As String, Key As String, TargetProfileID As String) As String Implements IFMSServer.GetState
    202. Initialize()
    203. If Key <> Keys(OwnProfileID) Then
    204. Return Nothing
    205. End If
    206. For Each s As Profile In Familys(Profiles(OwnProfileID).Family).FamilyMembers
    207. If s.ID = TargetProfileID Then
    208. Return Profiles(TargetProfileID).State
    209. End If
    210. Next
    211. Return Nothing
    212. End Function
    213. Public Function SetIsOnline(ProfileID As String, Key As String, IsOnline As Boolean) As Boolean Implements IFMSServer.SetIsOnline
    214. Initialize()
    215. If Key <> Keys(ProfileID) Then
    216. Return Nothing
    217. End If
    218. Profiles(ProfileID).IsOnline = IsOnline
    219. Return True
    220. End Function
    221. Public Function SetState(ProfileID As String, Key As String, State As String) As Boolean Implements IFMSServer.SetState
    222. Initialize()
    223. If Key <> Keys(ProfileID) Then
    224. Return Nothing
    225. End If
    226. Profiles(ProfileID).State = State
    227. Return True
    228. End Function
    229. End Class




    Code von der IFMSServer.vb:

    Spoiler anzeigen

    VB.NET-Quellcode

    1. ' HINWEIS: Mit dem Befehl "Umbenennen" im Kontextmenü können Sie den Schnittstellennamen "IService1" sowohl im Code als auch in der Konfigurationsdatei ändern.
    2. <ServiceContract()>
    3. Public Interface IFMSServer
    4. <OperationContract()>
    5. Function GetProfile(ByVal ProfileID As String, ByVal key As String) As Profile
    6. <OperationContract()>
    7. Function GetOtherProfile(ByVal ProfileID As String, ByVal key As String, ByVal TargetProfileID As String) As Profile
    8. <OperationContract()>
    9. Function GetFamily(ByVal FamilyID As String, ByVal ProfileID As String, ByVal key As String) As Family
    10. <OperationContract()>
    11. Function GetChats(ByVal ProfileID As String, ByVal key As String) As System.Collections.Generic.List(Of ChatRoom)
    12. <OperationContract()>
    13. Function CheckNewMessage(ByVal ProfileID As String, ByVal Key As String) As Boolean
    14. <OperationContract()>
    15. Function SendMessage(ByVal ProfileID As String, ByVal Key As String, ByVal Message As String, ByVal ChatRoomID As String) As Boolean
    16. <OperationContract()>
    17. Function GetNewMessages(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.List(Of Message)
    18. <OperationContract()>
    19. Function SetIsOnline(ByVal ProfileID As String, ByVal Key As String, ByVal IsOnline As Boolean) As Boolean
    20. <OperationContract()>
    21. Function SetState(ByVal ProfileID As String, ByVal Key As String, ByVal State As String) As Boolean
    22. <OperationContract()>
    23. Function GetState(ByVal OwnProfileID As String, ByVal Key As String, ByVal TargetProfileID As String) As String
    24. <OperationContract()>
    25. Function CheckNewState(ByVal ProfileID As String, ByVal Key As String) As Boolean
    26. <OperationContract()>
    27. Function GetNewState(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.Dictionary(Of String, String)
    28. End Interface
    29. <DataContract()>
    30. Public Class Profile
    31. Friend Function GetChatRoomList() As System.Collections.Generic.List(Of ChatRoom)
    32. Dim a As New System.Collections.Generic.List(Of ChatRoom)
    33. For Each b As String In ChatRooms
    34. a.Add(FMS_Server_WCF.FMSServer.ChatRooms(b))
    35. Next
    36. Return a
    37. End Function
    38. <DataMember()>
    39. Public IsOnline As Boolean
    40. <DataMember()>
    41. Public State As String
    42. <DataMember()>
    43. Public IsNewMessageAvailable As Boolean
    44. <DataMember()>
    45. Public ID As String
    46. <DataMember()>
    47. Public Family As String
    48. <DataMember()>
    49. Public Name As String
    50. <DataMember()>
    51. Public ChatRooms As New System.Collections.Generic.List(Of String)
    52. <DataMember()>
    53. Public States As New System.Collections.Generic.Dictionary(Of String, String)
    54. End Class
    55. <DataContract()>
    56. Public Class ChatRoom
    57. <DataMember()>
    58. Public ID As String
    59. <DataMember()>
    60. Public Messages As New System.Collections.Generic.List(Of Message)
    61. <DataMember()>
    62. Public IsSinglePersonChat As Boolean
    63. <DataMember()>
    64. Public Family As String
    65. <DataMember()>
    66. Public WithPs As New System.Collections.Generic.List(Of String)
    67. Friend Function GetWithPsList() As System.Collections.Generic.List(Of Profile)
    68. Dim a As New System.Collections.Generic.List(Of Profile)
    69. For Each b As Integer In WithPs
    70. a.Add(FMS_Server_WCF.FMSServer.Profiles(b))
    71. Next
    72. Return a
    73. End Function
    74. Public Sub New()
    75. End Sub
    76. Public Sub New(IsSinglePersonChat As Boolean, Family As Family, WithPs As System.Collections.Generic.List(Of String), ByVal ChatRoomID As String, Optional ByVal Name As String = "")
    77. Me.IsSinglePersonChat = IsSinglePersonChat
    78. Me.Family = Family.Family_ID
    79. Me.WithPs = WithPs
    80. Me.ID = ChatRoomID
    81. 'Messages.Add(New Message With {.From = 11111, .Message = "Hello you!"})
    82. 'For Each i As Integer In WithPs
    83. ' Messages(0).IsNew.Add(i, True)
    84. 'Next
    85. End Sub
    86. End Class
    87. <DataContract()>
    88. Public Class Family
    89. <DataMember()>
    90. Public Family_ID As String
    91. <DataMember()>
    92. Public Family_Name As String
    93. <DataMember()>
    94. Public FamilyMembers As New System.Collections.Generic.List(Of Profile)
    95. End Class
    96. <DataContract()>
    97. Public Class Message
    98. <DataMember()>
    99. Public From As String
    100. <DataMember()>
    101. Public Message As String
    102. <DataMember()>
    103. Public IsNew As New System.Collections.Generic.Dictionary(Of String, Boolean)
    104. End Class




    Und noch der Code-Snippet:

    Spoiler anzeigen

    VB.NET-Quellcode

    1. Imports FMS.FMSServer
    2. Public Class GlobalData
    3. Private Sub New()
    4. End Sub
    5. Friend Shared Property ThisChat As FMSServer.ChatRoom
    6. Friend Shared Property MyProfile As FMSServer.Profile
    7. Friend Shared Property MyFamily As FMSServer.Family
    8. Friend Shared Property MyID As String = "std"
    9. Friend Shared Property MyKey As String = "std"
    10. Friend Shared Sub Initialize()
    11. Dim cl As New FMSServerClient()
    12. AddHandler cl.GetFamilyCompleted, New EventHandler(Of FMSServer.GetFamilyCompletedEventArgs) _
    13. (Sub(sender As Object, GFCEA As FMSServer.GetFamilyCompletedEventArgs)
    14. MyFamily = GFCEA.Result
    15. End Sub)
    16. AddHandler cl.GetProfileCompleted, New EventHandler(Of FMSServer.GetProfileCompletedEventArgs) _
    17. (Sub(sender As Object, GPCEA As FMSServer.GetProfileCompletedEventArgs)
    18. MyProfile = GPCEA.Result
    19. End Sub)
    20. cl.GetFamilyAsync("", GlobalData.MyID, GlobalData.MyKey)
    21. cl.GetProfileAsync(GlobalData.MyID, GlobalData.MyKey)
    22. End Sub
    23. End Class




    Dann habe ich noch die Reference.vb (falls benötigt):

    pastebin.com/x4VuUdHQ



    Ich glaube dass dass an dem Phone liegt, weil das ja mit verschiedenen Sachen nicht gefunkt hat, ich weis es aber nicht. (Muss man dass voher der App erlauben?)

    (Weis einer eine Alternative zu WCF, .NET Remoting etc.? (Außer ServiceStack ;-)))

    Viele Grüße

    Skripter5000