我有这个网络服务:
namespace SUS.Web.Services
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class PublicServices:BaseService
{
public PublicServices()
: base(false)
{ }
[OperationContract]
public ObservableCollection<VmSolution> GetSolutions()
{
SusConfigurationSection solutionCofigurationsSection = (SusConfigurationSection)System.Configuration.ConfigurationManager.GetSection("SolutionConfigurations");
return solutionCofigurationsSection.GetVmSolutions();
}
[OperationContract]
public string Authenticate(ref VmLogin vmLogin)
{
vmLogin.ErrorMessage = "test message";
return "";
}
}
}
问题在于,当我从Silverlight调用Authenticate方法时,ErrorMessage属性包含字符串“test message”,但此值不会传播到传递的clientVmLogin对象。
public partial class LoginPage : UserControl
{
VmLogin clientVmLogin = new VmLogin();
PublicServicesClient proxyPublic;
public LoginPage()
{
DevExpress.Xpf.Core.ThemeManager.ApplicationTheme = DevExpress.Xpf.Core.Theme.Office2007Blue;
InitializeComponent();
proxyPublic = new PublicServicesClient();
proxyPublic.Endpoint.Address = new EndpointAddress(WebServiceHelper.GetWebserviceFolderAddress() + "PublicServices.svc");
proxyPublic.InnerChannel.OperationTimeout = WebServiceHelper.GetTimeOut();
proxyPublic.AuthenticateCompleted += new EventHandler<AuthenticateCompletedEventArgs>(proxyPublic_AuthenticateCompleted);
proxyPublic.GetSolutionsCompleted += new EventHandler<GetSolutionsCompletedEventArgs>(proxyPublic_GetSolutionsCompleted);
this.DataContext = clientVmLogin;
clientVmLogin.LoginNeeded+=new EventHandler(login_LoginNeeded);
Loaded += new RoutedEventHandler(LoginPage_Loaded);
}
void proxyPublic_poslinuggetCompleted(object sender, poslinuggetCompletedEventArgs e)
{
int i = 0;
}
void login_LoginNeeded(object sender, EventArgs e)
{
proxyPublic.AuthenticateAsync(this.clientVmLogin);
}
void proxyPublic_AuthenticateCompleted(object sender, AuthenticateCompletedEventArgs e)
{
if (this.clientVmLogin.ErrorMessage != e.vmLogin.ErrorMessage)
{
// i have problem. Ref is not working at all.
}
}
你知道吗,请问哪里有问题?我是唯一一个将使用我的wcf服务的人,因此我希望使用ref参数传递自动更新客户端对象。
非常感谢你。
汤姆