我是 WCF 技术的新手。我目前的问题是我的 Windows 窗体应用程序没有从 wcf 程序得到响应。这是我的 Windows 窗体应用程序的代码:
WCFService.PMSService obj = new WCFService.PMSService();
string xx = obj.Test("Hello");
MessageBox.Show(xx);
我的 Windows 窗体应用程序挂在这一行 -> string xx = obj.Test("Hello");
这是 wcf 我的程序的代码:
接口/声明页面
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IPMSService
{
[OperationContract]
string DetermineGender(PersonalInfo pInfo);
[OperationContract]
string Test(string val);
}
[DataContract]
public enum Gender
{
[EnumMember]
Male,
[EnumMember]
Female,
[EnumMember]
None
}
// Use a data contract as illustrated in the sample below to add composite types to service operations
[DataContract]
public class PersonalInfo
{
[DataMember]
public string name
{
get { return name; }
set { name = value; }
}
[DataMember]
public string surname
{
get { return surname; }
set { surname = value; }
}
[DataMember]
public string idNo
{
get { return idNo; }
set { idNo = value; }
}
实施页面
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class PMSService : IPMSService
{
public string DetermineGender(PersonalInfo pInfo)
{
Gender Result = Gender.None;
int idNo = Convert.ToInt32(pInfo.idNo.Substring(6, 4));
if (idNo >= 5000)
Result = Gender.Male;
else
Result = Gender.Female;
return Result.ToString();
}
public string Test(string val)
{
return "U passed " + val;
}
}
有人知道可能的原因吗?