私は認証と呼ばれるメソッドを宣言しました。このメソッドはAuthenticationRequestを入力として受け取ります。これは私の問題が始まるところです。 AuthenicationRequestのユーザー名とパスワードの変数をプライベートに設定しています。そのため、オーバーロードされたコンストラクタを使用してそれらを返すように設定しています。私のクライアントではAuthentication(new AuthenticationRequest("","")
を呼び出そうとしています)、オーバーロードされたコンストラクタは認識されません。私はC#WCFサービスを使用しています。私はWebアドレスからクライアントコードを生成するためにVisual Studioを使用しています。 以下、クラスのコピーを投稿します。私は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メソッドはクライアント側では見られません。 –
ベイリー、私はその質問にも役立つより徹底的な回答をタイプしています。 –