12,162
社区成员
发帖
与我相关
我的任务
分享
public class Service1 : IService1
{
[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
public string GetData(string ClientIdentity)
{
return ("成功调用");
}
}
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string ClientIdentity);
// TODO: 在此添加您的服务操作
}
ServiceReference1.Service1Client data = new ServiceReference1.Service1Client();
NetworkCredential credential = data.ChannelFactory.Credentials.Windows.ClientCredential;
credential.UserName = "jbye";
credential.Password = "bao.123";
IService1 calculator = data.ChannelFactory.CreateChannel();
MessageBox.Show(calculator.GetData("123"));