Я объявил метод под названием Аутентификация, этот метод принимает в качестве входного параметра AuthenticationRequest. Так вот начинается моя проблема. Я установил переменные имени пользователя и пароля в AuthenicationRequest в private, поэтому я использую перегруженный конструктор, чтобы установить их и getters для их возврата. На моем клиенте я пытаюсь позвонить Authentication(new AuthenticationRequest("","")
), однако перегруженный конструктор не распознается. Я пользуюсь услугами C# WCF. Я использую визуальную студию для создания кода клиента с веб-адреса. Ниже я отправлю копии моих классов. Я не очень много знаю о WCF, но из того, что я понимаю, вам нужны определенные атрибуты [Атрибуты].C# Объекты SVC-сервера имеют общедоступные методы, объекты-клиенты не
AuthenticationRequest
using Classes.General;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Web;
namespace Classes.Authentication
{
[DataContract]
public class AuthenicationRequest : Status
{
[DataMember]
private String Email, Password;
public AuthenicationRequest(String Email, String Password)
{
this.Email = Email;
this.Password = Password;
}
public void doWork()
{
}
public String GetEmail()
{
return this.Email;
}
public String GetPassword()
{
return this.Password;
}
}
}
Authentication.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using MySql.Data.MySqlClient;
using Classes.General;
using Classes.Users;
using Classes.Authentication;
namespace WebApi_Nepp_Studios.Endpoints
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Authentication" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Authentication.svc or Authenication.svc.cs at the Solution Explorer and start debugging.
[ServiceContract]
public class Authentication
{
//Declare the MySQL variable for global databse operations
MySqlConnection conn = new MySqlConnection(Properties.Resources.Cs);
MySqlCommand cmd;
MySqlDataReader reader;
[OperationContract]
public AuthenicationResponse Authenicate(AuthenicationRequest input)
{
//Blah blah blah
}
}
}
Я бы посоветовал вам посмотреть на этот ответ http://stackoverflow.com/questions/6316118/constructor-in-wcf-datacontract-not-reflected-on-client –
Хорошо, что отвечает на мой вопрос, спасибо. Однако я столкнулся с другой проблемой. Мой метод DoWork не рассматривается на стороне клиента. –
Бейли, я печатаю более тщательный ответ, который также должен помочь в этом вопросе. –