Bonjour à tous,
J'essaie de passer en argument à une de mes méthodes webservice une classe.
Je ne sais pas trop comment faire, j'ai crée ma classe du coté webservice et j'essaie de l'appeler du coté client mais il me dit qu'il ne trouve pas le constructeur
voici une partie de l'arborescence des classes de mon web service :
Voici la méthode de mon web service :
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 [WebMethod (EnableSession = true, Description = "PROCESS : Cette fonction permet l'authentification par formulaire<BR>" + "PROTOTYPE : public string Login( string UserName, string password)<BR>" + "PARAMETRES : 1.string UserName 2.string Password<BR>" + "RETURN : LogOk ou LogNOk<BR>" )] public void Login(/*string UserName, string Password*/ Client client) { try { // if (IsAuthenticated == true) // throw new YetAuthenticatedException(); // else // { IsAuthenticated = false; string Password_From_Server = dbCon.Select(Constantes.SELECT_PASSWORD_FROM_CLIENT_BY_USERNAME, "@UserName", client.getUsername()); System.Console.WriteLine("password: " + Password_From_Server); // } } catch (Exception exc) { throw RaiseException("Fonction Login", @"E:\ECOLE\3TROISIEME_ANNEE\2006-2007\COURS\Systèmes Distribués\Labo\WEB_SERVICES\SERVEUR_WEB_SERVICE\App_Code\Service.asmx", exc.Message, "2006", "Fonction Login", FaultCode.Client); } }
Code de la classe client:
Code du coté client:
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
47
48
49
50
51
52
53
54
55 using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// <summary> /// Summary description for Client /// </summary> [Serializable] public class Client : Intervenant { public string username; public string password; public Client() { } public Client(string username, string password) : base() { this.username = username; this.password = password; } public Client( string username, string password, int idIntervenant, string nom, string prenom ) : base(idIntervenant,nom,prenom) { this.username = username; this.password = password; } public Client(string username, string password, int idIntervenant, string nom, string prenom, string adresse) : base(idIntervenant,nom,prenom,adresse) { this.username = username; this.password = password; } public Client(string username, string password, int idIntervenant, string nom, string prenom, string adresse, string telephone) : base(idIntervenant,nom,prenom,adresse,telephone) { this.username = username; this.password = password; } public Client(string username, string password, int idIntervenant, string nom, string prenom, string adresse, string telephone, string email): base(idIntervenant,nom,prenom,adresse,telephone,email) { this.username = username; this.password = password; } public string getUsername() { return username; } public string getPassword() { return password; } }
L'erreur que j'obtiens:
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 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using webservice; public partial class _Default : System.Web.UI.Page { //private POO_WS.Service service = null; private webservice.WebService ws = null; protected void Page_Load(object sender, EventArgs e) { //service = (POO_WS.Service)Session["Id"]; ws = (webservice.WebService)Session["Id"]; } protected void btnLogin_Click(object sender, EventArgs e) { try { //Client client = new Client( tbxUserName.Text, tbxPassword.Text ); //service.Login(tbxUserName.Text, tbxPassword.Text); //service.Login( new Client(tbxUserName.Text, tbxPassword.Text) ); //Client client = new Client(tbxUserName.Text, tbxPassword.Text); ws.Login(new Client(tbxUserName.Text, tbxPassword.Text)); Response.Redirect("PageInformation.aspx?info=Authentification réussie, bienvenue "+tbxUserName.Text); } catch ( Exception exc) { lblRéponse.Text = exc.Message; } } }
Error 1 No overload for method 'Client' takes '2' arguments
J'ai aussi le problème que quand je ne mets pas de constructeur par défaut dans la classe client, il me lance une erreur... pour ne pas me disperser,si quelqu'un pouvait me dire comment faire pour faire transiter des classes correctement, ce serait vraiment très gentil
Partager