Salut tout le monde, je suis nouveau en .Net et surtout Silverlight + WCF
donc j'ai une solution en couches :
DAL : Entity Framework
DAO : pour les CRUD
Silverlight : pour les interfaces
et Web
donc je veut afficher une DataGrid avec une List<Person> de la base en utilisant les wcf et entity framework.
l'erreur que j'ai :et en utilisant Fiddler j'ai l'exception :Server NotFound
mon service WCF :System.Xml.XmlException: Le préfixe «*x*» n’est pas défini.
à System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
à System.Xml.XmlBaseReader.LookupNamespace(PrefixHandleType prefix)
à System.Xml.XmlBinaryReader.ReadNode()
à System.Xml.XmlBinaryReader.Read()
à System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
à System.Xml.XmlDocument.Load(XmlReader reader)
à BinaryMessageFiddlerExtension.BinaryInspector.LoadMessageIntoDocument(Byte[] encodedMessage)
à BinaryMessageFiddlerExtension.BinaryInspector.GetWcfBinaryMessageAsText(Byte[] encodedMessage)
à BinaryMessageFiddlerExtension.BinaryInspector.UpdateView(Byte[] bytes)
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 { [OperationContract] public List<PERSON> getAllPerson() { Class1 c = new Class1(); List<PERSON> listedepersonne; listedepersonne = c.getAllFacilities(); return listedepersonne; } } }
mon fichier web.config coté serveur
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <connectionStrings> <add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=localhost/xe;PASSWORD=rami;PERSIST SECURITY INFO=True;USER ID=RAMI"" providerName="System.Data.EntityClient" /> </connectionStrings> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding name="SilverlightApplication1.Web.Service1.customBinding0"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> <services> <service name="SilverlightApplication1.Web.Service1"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SilverlightApplication1.Web.Service1.customBinding0" contract="SilverlightApplication1.Web.Service1" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel> </configuration>
(j'ai essayer le basicHttpBinding et custumBinding )
mon fichier de binding coté client :
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:53225/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1" name="BasicHttpBinding_Service1" /> </client> </system.serviceModel> </configuration>
et biensur l'appel coté client (silverlight 4) :
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 private void datagrid(object sender, RoutedEventArgs e) { ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); client.getAllPersonCompleted +=new EventHandler<ServiceReference1.getAllPersonCompletedEventArgs>(client_getAllPersonCompleted); client.getAllPersonAsync(); } private void client_getAllPersonCompleted(object sender, ServiceReference1.getAllPersonCompletedEventArgs e) { dataGrid1.ItemsSource = e.Result; }
ça fait 3 jourset j'ai presque fouillé tout le net
quelqu'un a rencontré cette exception ?!
merci pour votre aide.
Partager