Bonjour j'ai voulu faire l’excellent article de Ludovic Lefort sur le sujet.
En locale pas de soucis tout fonctionne très bien
j'ai voulu faire le test avec un serveur sql express 2008 R2
IIS 7 sur un Windows 2008 server
tout ça dans une petite VM sur mon poste
Ça marche pas (je bidouille à gauche et à droite, toujours des erreurs)
PS: je suis un gros débutant et très mauvais lol
voici mes lignes de codes
MainPage.xaml.cs
ServiceReferences.ClientConfig
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 void client_getUsernameCompleted(object sender, IntraInfoServiceReference.getUtilisateursCompletedEventArgs e) { dataGrid1.ItemsSource = e.Result; } private void button1_Click(object sender, RoutedEventArgs e) { IntraInfoServiceReference.IntraInfoServiceClient client = new IntraInfoServiceReference.IntraInfoServiceClient(); client.getUtilisateursCompleted += new EventHandler<IntraInfoServiceReference.getUtilisateursCompletedEventArgs>(client_getUsernameCompleted); client.getUtilisateursAsync(); }
IntraInfoService.svc
Code : 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> <customBinding> <binding name="CustomBinding_IntraInfoService"> <binaryMessageEncoding /> <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> </binding> </customBinding> </bindings> <client> <endpoint address="http://intra-info/IntraInfo/IntraInfoService.svc" binding="customBinding" bindingConfiguration="CustomBinding_IntraInfoService" contract="IntraInfoServiceReference.IntraInfoService" name="CustomBinding_IntraInfoService" /> </client> </system.serviceModel> </configuration>
Web.config
Code : 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 namespace IntraInfo.Web { //http://intra-info/intrainfo/IntraInfoService [ServiceContract(Namespace = "")] [SilverlightFaultBehavior] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class IntraInfoService { [OperationContract] public List<Utilisateurs> getUtilisateurs() { DataCIntraInfoDataContext dc = new DataCIntraInfoDataContext(); var ALLusers = from users in dc.Utilisateurs orderby users.Username select users; return ALLusers.ToList(); } [OperationContract] public string searchPassword(string username) { return "test"; } // Ajoutez des opérations supplémentaires ici et marquez-les avec [OperationContract] } }
Comme service j'ai utilisé service compatible silverlight dans visual studio
Code : 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
38
39
40
41
42
43
44
45
46 <?xml version="1.0" encoding="utf-8"?> <!-- Pour plus d'informations sur la configuration de votre application ASP.NET, consultez http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="DBIntraInfoConnectionString" connectionString="Data Source=intra-info\sqlexpress;Initial Catalog=DBIntraInfo;Persist Security Info=True;User ID=sa;Password=aaaaaaaa" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings> <customBinding> <binding name="IntraInfo.Web.IntraInfoService.customBinding0"> <binaryMessageEncoding /> <httpTransport /> </binding> </customBinding> </bindings> <services> <!--customBinding basicHttpBinding--> <service name="IntraInfo.Web.IntraInfoService"> <endpoint address="" binding="customBinding" bindingConfiguration="IntraInfo.Web.IntraInfoService.customBinding0" contract="IntraInfo.Web.IntraInfoService" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> </configuration>
voici une erreur en Pj
V s aVD ��Xhttp://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/faultD�<]��KI��$�m5�VV�V�V��s�:�ReceiverV�V� aRhttp://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher�a�:�InternalServiceFaultV�V�xmllang�fr-FR�jLe format de la chaîne d'initialisation n'est pas conforme à la spécification qui débute à l'index 0.V�@ExceptionDetail;http://schemas.datacontract.org/2004...m.ServiceModel i)http://www.w3.org/2001/XMLSchema-ins...age�jLe format de la chaîne d'initialisation n'est pas conforme à la spécification qui débute à l'index 0.@ StackTrace� à System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) à System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) à System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) à System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) à System.Data.Linq.SqlClient.SqlProvider.GetDatabaseName(String constr) à System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(IDataServices dataServices, Object connection) à System.Data.Linq.DataContext.Init(Object connection, MappingSource mapping) à IntraInfo.Web.DataCIntraInfoDataContext..ctor() dans C:\Documents and Settings\gervaisT\mes documents\visual studio 2010\Projects\IntraInfo\IntraInfo.Web\DataCIntraInfo.designer.cs:ligne 39 à IntraInfo.Web.IntraInfoService.getUtilisateurs() dans C:\Documents and Settings\gervaisT\mes documents\visual studio 2010\Projects\IntraInfo\IntraInfo.Web\IntraInfoService.svc.cs:ligne 21 à SyncInvokegetUtilisateurs(Object , Object[] , Object[] ) à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)@Type�System.ArgumentException
Avez vous une idée ?
et comment vous faites pour debugé votre projet en locale et l'envoyer sur votre serveur final sans ajouter une nouvelle référence de service ?
Si une personne à un tuto de A à Z , sur creation d'un appli silverlight avec wcf et sql, ou la configuration de IIS et sql est bien expliqué je suis preneur
Merci d'avance pour votre aide.
Thomas
Partager