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
Mein Code ist der folgende vom Server (FMSServer.svc.vb):
Spoiler anzeigen
Code von der IFMSServer.vb:
Spoiler anzeigen
Und noch der Code-Snippet:
Spoiler anzeigen
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
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:
Quellcode
- {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.
- at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
- at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
- at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
- --- End of inner exception stack trace ---
- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
- at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
- at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
- --- End of inner exception stack trace ---
- at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
- at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
- at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
- at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.HelloWorldSoapClientChannel.EndGetHello(IAsyncResult result)
- at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.ServiceStackHWWPClient.HelloWorld.HelloWorldSoap.EndGetHello(IAsyncResult result)
- at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.EndGetHello(IAsyncResult result)
- at ServiceStackHWWPClient.HelloWorld.HelloWorldSoapClient.OnEndGetHello(IAsyncResult result)
- at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
- InnerException:
- {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
- at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
- at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
- at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
- --- End of inner exception stack trace ---
- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
- at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
- at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}
Mein Code ist der folgende vom Server (FMSServer.svc.vb):
VB.NET-Quellcode
- ' 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.
- ' 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.
- Public Class FMSServer
- Implements IFMSServer
- Friend Shared Profiles As New System.Collections.Generic.Dictionary(Of String, Profile)
- Private Shared Keys As New System.Collections.Generic.Dictionary(Of String, String)
- Friend Shared Familys As New System.Collections.Generic.Dictionary(Of String, Family)
- Friend Shared ChatRooms As New System.Collections.Generic.Dictionary(Of String, ChatRoom)
- Private Shared Initializeda As Boolean = False
- Public Sub Initialize()
- If Initializeda Then
- Return
- End If
- Initializeda = True
- Dim f As New Family()
- Dim p1 As New Profile()
- Dim p2 As New Profile()
- Dim p3 As New Profile()
- Dim p4 As New Profile()
- Dim p5 As New Profile()
- Dim admin As New Profile()
- f.Family_ID = "std"
- p1.ID = "aaa"
- p2.ID = "bbb"
- p3.ID = "ccc"
- p4.ID = "ddd"
- p5.ID = "eee"
- admin.ID = "fff"
- 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")
- Dim c12 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p2.ID}), "43CDC115-5C46-4493-A4D2-57290843EC04")
- Dim c13 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p3.ID}), "4FAF572F-84AA-40D7-B703-493D4F5FFC07")
- Dim c14 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p4.ID}), "44415ED7-4C3B-4400-8423-12A1EF90E9BF")
- Dim c15 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p1.ID, p5.ID}), "204EC6F3-AEED-4F87-98F6-6FF5548C9AF2")
- Dim c23 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p3.ID}), "AD6C3DC7-E3ED-4D7D-A3F7-21ECB89D0397")
- Dim c24 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p4.ID}), "FEE15387-5224-49A4-958D-EB1F9E1E9D26")
- Dim c25 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p2.ID, p5.ID}), "AF58B405-58A2-443E-ACAC-AD09898A60E7")
- Dim c34 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p3.ID, p4.ID}), "E2EA4056-116A-4BAD-AFC2-823E651DAF1F")
- Dim c35 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p3.ID, p5.ID}), "1D14FEA3-AEAD-471B-8FBD-FF6815285562")
- Dim c45 As New ChatRoom(True, f, New System.Collections.Generic.List(Of String)({p4.ID, p5.ID}), "0B0B8621-E0B9-41FE-9E86-17EA13610213")
- f.Family_Name = "std"
- f.FamilyMembers.Add(p1)
- f.FamilyMembers.Add(p2)
- f.FamilyMembers.Add(p3)
- f.FamilyMembers.Add(p4)
- f.FamilyMembers.Add(p5)
- p1.Name = "std"
- p1.Family = f.Family_ID
- p1.ChatRooms.AddRange({c12.ID, c13.ID, c14.ID, c15.ID, fc.ID})
- p2.Name = "std"
- p2.Family = f.Family_ID
- p2.ChatRooms.AddRange({c12.ID, c23.ID, c24.ID, c25.ID, fc.ID})
- p3.Name = "std"
- p3.Family = f.Family_ID
- p3.ChatRooms.AddRange({c13.ID, c23.ID, c34.ID, c35.ID, fc.ID})
- p4.Name = "std"
- p4.Family = f.Family_ID
- p4.ChatRooms.AddRange({c14.ID, c24.ID, c34.ID, c45.ID, fc.ID})
- p5.Name = "std"
- p5.Family = f.Family_ID
- p5.ChatRooms.AddRange({c15.ID, c25.ID, c35.ID, c45.ID, fc.ID})
- Profiles.Add(p1.ID, p1)
- Profiles.Add(p2.ID, p2)
- Profiles.Add(p3.ID, p3)
- Profiles.Add(p4.ID, p4)
- Profiles.Add(p5.ID, p5)
- Familys.Add(f.family_ID, f)
- ' Passwort immer mit 35 Zeichen
- Keys.Add("aaa", "aaa") ' Verschleiert
- Keys.Add("bbb", "bbb")
- Keys.Add("ccc", ccc")
- Keys.Add("ddd", "ddd")
- Keys.Add("eee", "eee")
- Keys.Add("fff", "fff")
- ChatRooms.Add(c12.ID, c12)
- ChatRooms.Add(c13.ID, c13)
- ChatRooms.Add(c14.ID, c14)
- ChatRooms.Add(c15.ID, c15)
- ChatRooms.Add(c23.ID, c23)
- ChatRooms.Add(c24.ID, c24)
- ChatRooms.Add(c25.ID, c25)
- ChatRooms.Add(c34.ID, c34)
- ChatRooms.Add(c35.ID, c35)
- ChatRooms.Add(c45.ID, c45)
- ChatRooms.Add(fc.ID, fc)
- End Sub
- Public Function GetProfile(ByVal ProfileID As String, ByVal key As String) As Profile Implements IFMSServer.GetProfile
- Initialize()
- If key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Dim p As Profile = Profiles(ProfileID)
- Return p
- End Function
- Public Function GetOtherProfile(ByVal ProfileID As String, ByVal key As String, ByVal TargetProfileID As String) As Profile Implements IFMSServer.GetOtherProfile
- Initialize()
- If key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Dim p As Profile = Profiles(TargetProfileID)
- If Not p.Family = Profiles(ProfileID).Family Then
- Return Nothing
- End If
- Return p
- End Function
- Public Function GetFamily(ByVal FamilyID As String, ByVal ProfileID As String, ByVal key As String) As Family Implements IFMSServer.GetFamily
- Initialize()
- If key <> Keys(ProfileID) Then
- Return Nothing
- End If
- If FamilyID = "" Then
- Return Familys(Profiles(ProfileID).Family)
- End If
- If Profiles(ProfileID).Family <> FamilyID Then
- Return Nothing
- End If
- Return Familys(FamilyID)
- End Function
- Public Function GetChats(ByVal ProfileID As String, ByVal key As String) As System.Collections.Generic.List(Of ChatRoom) Implements IFMSServer.GetChats
- Initialize()
- If key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Return Profiles(ProfileID).GetChatRoomList
- End Function
- Public Function CheckNewMessage(ByVal ProfileID As String, ByVal Key As String) As Boolean Implements IFMSServer.CheckNewMessage
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Return GetProfile(ProfileID, Key).IsNewMessageAvailable
- End Function
- Public Function SendMessage(ByVal ProfileID As String, ByVal Key As String, ByVal Message As String, ByVal ChatRoomID As String) As Boolean Implements IFMSServer.SendMessage
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return False
- End If
- Dim a As Boolean
- For Each c As String In Profiles(ProfileID).ChatRooms
- If c = ChatRoomID Then
- a = True
- End If
- Next
- If Not a Then
- Return Nothing
- End If
- Dim cr1 As ChatRoom
- For Each cr As ChatRoom In GetProfile(ProfileID, Key).GetChatRoomList()
- If cr.ID = ChatRoomID Then
- cr1 = cr
- GoTo HaveAGoodDay
- End If
- Next
- Return False
- HaveAGoodDay: Dim m As New Message() With {.From = ProfileID, .Message = Message}
- cr1.Messages.Add(m)
- For Each p As Profile In cr1.GetWithPsList
- p.IsNewMessageAvailable = True
- m.IsNew.Add(p.ID, True)
- Next
- Return True
- End Function
- Public Function GetNewMessages(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.List(Of Message) Implements IFMSServer.GetNewMessages
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Dim EMA As New System.Collections.Generic.List(Of Message)
- For Each CR As ChatRoom In GetProfile(ProfileID, Key).GetChatRoomList
- For Each M As Message In CR.Messages
- If M.IsNew(ProfileID) Then
- M.IsNew(ProfileID) = False
- EMA.Add(M)
- Profiles(ProfileID).IsNewMessageAvailable = False
- End If
- Next
- Next
- Return EMA
- End Function
- Public Function CheckNewState(ProfileID As String, Key As String) As Boolean Implements IFMSServer.CheckNewState
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return Nothing
- End If
- For Each d As System.Collections.Generic.KeyValuePair(Of String, String) In Profiles(ProfileID).States
- If Profiles(d.Key).State = d.Value Then
- Return True
- End If
- Next
- Return False
- End Function
- Public Function GetNewState(ProfileID As String, Key As String) As Dictionary(Of String, String) Implements IFMSServer.GetNewState
- Initialize()
- Dim a As New Dictionary(Of String, String)
- For Each s As Generic.KeyValuePair(Of String, String) In Profiles(ProfileID).States
- If s.Value <> Profiles(s.Key).State Then
- a.Add(s.Key, Profiles(s.Key).State)
- End If
- Next
- Return a
- End Function
- Public Function GetState(OwnProfileID As String, Key As String, TargetProfileID As String) As String Implements IFMSServer.GetState
- Initialize()
- If Key <> Keys(OwnProfileID) Then
- Return Nothing
- End If
- For Each s As Profile In Familys(Profiles(OwnProfileID).Family).FamilyMembers
- If s.ID = TargetProfileID Then
- Return Profiles(TargetProfileID).State
- End If
- Next
- Return Nothing
- End Function
- Public Function SetIsOnline(ProfileID As String, Key As String, IsOnline As Boolean) As Boolean Implements IFMSServer.SetIsOnline
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Profiles(ProfileID).IsOnline = IsOnline
- Return True
- End Function
- Public Function SetState(ProfileID As String, Key As String, State As String) As Boolean Implements IFMSServer.SetState
- Initialize()
- If Key <> Keys(ProfileID) Then
- Return Nothing
- End If
- Profiles(ProfileID).State = State
- Return True
- End Function
- End Class
Code von der IFMSServer.vb:
VB.NET-Quellcode
- ' HINWEIS: Mit dem Befehl "Umbenennen" im Kontextmenü können Sie den Schnittstellennamen "IService1" sowohl im Code als auch in der Konfigurationsdatei ändern.
- <ServiceContract()>
- Public Interface IFMSServer
- <OperationContract()>
- Function GetProfile(ByVal ProfileID As String, ByVal key As String) As Profile
- <OperationContract()>
- Function GetOtherProfile(ByVal ProfileID As String, ByVal key As String, ByVal TargetProfileID As String) As Profile
- <OperationContract()>
- Function GetFamily(ByVal FamilyID As String, ByVal ProfileID As String, ByVal key As String) As Family
- <OperationContract()>
- Function GetChats(ByVal ProfileID As String, ByVal key As String) As System.Collections.Generic.List(Of ChatRoom)
- <OperationContract()>
- Function CheckNewMessage(ByVal ProfileID As String, ByVal Key As String) As Boolean
- <OperationContract()>
- Function SendMessage(ByVal ProfileID As String, ByVal Key As String, ByVal Message As String, ByVal ChatRoomID As String) As Boolean
- <OperationContract()>
- Function GetNewMessages(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.List(Of Message)
- <OperationContract()>
- Function SetIsOnline(ByVal ProfileID As String, ByVal Key As String, ByVal IsOnline As Boolean) As Boolean
- <OperationContract()>
- Function SetState(ByVal ProfileID As String, ByVal Key As String, ByVal State As String) As Boolean
- <OperationContract()>
- Function GetState(ByVal OwnProfileID As String, ByVal Key As String, ByVal TargetProfileID As String) As String
- <OperationContract()>
- Function CheckNewState(ByVal ProfileID As String, ByVal Key As String) As Boolean
- <OperationContract()>
- Function GetNewState(ByVal ProfileID As String, ByVal Key As String) As System.Collections.Generic.Dictionary(Of String, String)
- End Interface
- <DataContract()>
- Public Class Profile
- Friend Function GetChatRoomList() As System.Collections.Generic.List(Of ChatRoom)
- Dim a As New System.Collections.Generic.List(Of ChatRoom)
- For Each b As String In ChatRooms
- a.Add(FMS_Server_WCF.FMSServer.ChatRooms(b))
- Next
- Return a
- End Function
- <DataMember()>
- Public IsOnline As Boolean
- <DataMember()>
- Public State As String
- <DataMember()>
- Public IsNewMessageAvailable As Boolean
- <DataMember()>
- Public ID As String
- <DataMember()>
- Public Family As String
- <DataMember()>
- Public Name As String
- <DataMember()>
- Public ChatRooms As New System.Collections.Generic.List(Of String)
- <DataMember()>
- Public States As New System.Collections.Generic.Dictionary(Of String, String)
- End Class
- <DataContract()>
- Public Class ChatRoom
- <DataMember()>
- Public ID As String
- <DataMember()>
- Public Messages As New System.Collections.Generic.List(Of Message)
- <DataMember()>
- Public IsSinglePersonChat As Boolean
- <DataMember()>
- Public Family As String
- <DataMember()>
- Public WithPs As New System.Collections.Generic.List(Of String)
- Friend Function GetWithPsList() As System.Collections.Generic.List(Of Profile)
- Dim a As New System.Collections.Generic.List(Of Profile)
- For Each b As Integer In WithPs
- a.Add(FMS_Server_WCF.FMSServer.Profiles(b))
- Next
- Return a
- End Function
- Public Sub New()
- End Sub
- 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 = "")
- Me.IsSinglePersonChat = IsSinglePersonChat
- Me.Family = Family.Family_ID
- Me.WithPs = WithPs
- Me.ID = ChatRoomID
- 'Messages.Add(New Message With {.From = 11111, .Message = "Hello you!"})
- 'For Each i As Integer In WithPs
- ' Messages(0).IsNew.Add(i, True)
- 'Next
- End Sub
- End Class
- <DataContract()>
- Public Class Family
- <DataMember()>
- Public Family_ID As String
- <DataMember()>
- Public Family_Name As String
- <DataMember()>
- Public FamilyMembers As New System.Collections.Generic.List(Of Profile)
- End Class
- <DataContract()>
- Public Class Message
- <DataMember()>
- Public From As String
- <DataMember()>
- Public Message As String
- <DataMember()>
- Public IsNew As New System.Collections.Generic.Dictionary(Of String, Boolean)
- End Class
Und noch der Code-Snippet:
VB.NET-Quellcode
- Imports FMS.FMSServer
- Public Class GlobalData
- Private Sub New()
- End Sub
- Friend Shared Property ThisChat As FMSServer.ChatRoom
- Friend Shared Property MyProfile As FMSServer.Profile
- Friend Shared Property MyFamily As FMSServer.Family
- Friend Shared Property MyID As String = "std"
- Friend Shared Property MyKey As String = "std"
- Friend Shared Sub Initialize()
- Dim cl As New FMSServerClient()
- AddHandler cl.GetFamilyCompleted, New EventHandler(Of FMSServer.GetFamilyCompletedEventArgs) _
- (Sub(sender As Object, GFCEA As FMSServer.GetFamilyCompletedEventArgs)
- MyFamily = GFCEA.Result
- End Sub)
- AddHandler cl.GetProfileCompleted, New EventHandler(Of FMSServer.GetProfileCompletedEventArgs) _
- (Sub(sender As Object, GPCEA As FMSServer.GetProfileCompletedEventArgs)
- MyProfile = GPCEA.Result
- End Sub)
- cl.GetFamilyAsync("", GlobalData.MyID, GlobalData.MyKey)
- cl.GetProfileAsync(GlobalData.MyID, GlobalData.MyKey)
- End Sub
- 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