C# Silverlight启用的wcf服务引用参数不工作
我有一个web服务:C# Silverlight启用的wcf服务引用参数不工作,c#,wcf,silverlight,parameters,ref,C#,Wcf,Silverlight,Parameters,Ref,我有一个web服务: namespace SUS.Web.Services { [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class PublicServices:BaseService { public PublicServices()
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 "";
}
}
namespace SUS.Web.Services
{
[ServiceContract(名称空间=”)]
[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
公共类公共服务:BaseService
{
公共服务()
:base(假)
{ }
[经营合同]
公共可观测集合GetSolutions()
{
SusConfigurationSection SolutionConfigurationsSection=(SusConfigurationSection)System.Configuration.ConfigurationManager.GetSection(“SolutionConfigurations”);
返回solutionCofigurationsSection.GetVmSolutions();
}
[经营合同]
公共字符串身份验证(ref VmLogin VmLogin)
{
vmLogin.ErrorMessage=“测试消息”;
返回“”;
}
}
}
问题是,当我从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.
}
}
public部分类登录页面:UserControl
{
VmLogin clientVmLogin=新建VmLogin();
PublicServicesClient proxyPublic;
公共登录页()
{
DevExpress.Xpf.Core.ThemeManager.ApplicationTheme=DevExpress.Xpf.Core.Theme.Office2007Blue;
初始化组件();
proxyPublic=新的PublicServicesClient();
proxyPublic.Endpoint.Address=新的端点地址(WebServiceHelper.GetWebserviceFolderAddress()+“PublicServices.svc”);
proxyPublic.InnerChannel.OperationTimeout=WebServiceHelper.GetTimeOut();
proxyPublic.AuthenticateCompleted+=新事件处理程序(proxyPublic\u AuthenticateCompleted);
proxyPublic.GetSolutionsCompleted+=新事件处理程序(proxyPublic\u GetSolutionsCompleted);
this.DataContext=clientVmLogin;
clientVmLogin.loginneded+=新事件处理程序(login\u loginneded);
已加载+=新路由EventHandler(登录页面已加载);
}
void proxyPublic_poslinuggetCompleted(对象发送方,poslinuggetCompletedEventArgs e)
{
int i=0;
}
void login\u loginneded(对象发送方,事件参数e)
{
proxyPublic.authenticateSync(this.clientVmLogin);
}
void proxyPublic\u AuthenticateCompleted(对象发送方,AuthenticateCompletedEventArgs e)
{
if(this.clientVmLogin.ErrorMessage!=e.vmLogin.ErrorMessage)
{
//我有问题,裁判根本不工作。
}
}
你知道,哪里会有问题吗?我是唯一一个会使用我的wcf服务的人,所以我想从使用ref参数传递的自动更新的客户端对象中获益
多谢各位
Tom为什么要在身份验证中返回字符串?您能否返回VmLogin对象并将其作为参数传递?我不确定,但我认为ref不会通过通道(WCF)工作你希望它能为你提供服务所做的更改。你好,利奥。谢谢你的帮助。这只是对ref-param的一个测试。没有真正的功能。我很确定类似ref-param的东西应该可以工作。我花了两个多小时在谷歌上搜索,我在这里和那里都有一些关于这方面的帖子。但我没有找到工作Simple代表Silverlight。我不认为您可以在WCF中使用by ref params-marc_在这里描述得很好:@Szymon这就是我在使用Silverlight代表RIA时所想的一切。请参阅MatteoSp评论。老实说,它已经在工作了,但我做了很多更改,它突然停止工作。我不知道为什么。