wcf ria服务方法返回
我有一个带有 wcf ria 服务的 Silverlight 站点,这只是一个测试。 该服务如下
[EnableClientAccess()]
public class PersonService : DomainService
{
[Invoke]
public string[] GetPersonNames()
{
return new string[] { "abc", "cba", "ddd", "ttt" };
}
[Invoke]
public string GetName()
{
return "teste";
}
[Invoke]
public string Test(string str)
{
return str;
}
}
我有一个 xaml 页面,我在其中调用该服务
SLRiaTest.Web.PersonContext person = new SLRiaTest.Web.PersonContext();
public MainPage()
{
InitializeComponent();
person.GetPersonNames(OnFinished,null);
}
private void OnFinished(InvokeOperation<string[]> obj)
{
var list = obj.Value;
}
,但值始终为空,并且我在服务中的断点永远不会被命中。我在互联网上到处搜索,找不到任何可以告诉我做错了什么的东西,任何帮助都会很棒,我很绝望......我想我可以在没有实体框架的情况下使用 RIA 服务?
I have a Silverlight site with wcf ria services, this is just a test.
The service is as follow
[EnableClientAccess()]
public class PersonService : DomainService
{
[Invoke]
public string[] GetPersonNames()
{
return new string[] { "abc", "cba", "ddd", "ttt" };
}
[Invoke]
public string GetName()
{
return "teste";
}
[Invoke]
public string Test(string str)
{
return str;
}
}
I have a xaml page where I call the service
SLRiaTest.Web.PersonContext person = new SLRiaTest.Web.PersonContext();
public MainPage()
{
InitializeComponent();
person.GetPersonNames(OnFinished,null);
}
private void OnFinished(InvokeOperation<string[]> obj)
{
var list = obj.Value;
}
but the Value is always null and the break point that I have in the serice never gets hit. I search the internet high and low and can't find anything that might tell me what I'm doing wrong, any help would be great, I'm desperate.... I suppose that I can use RIA service without entity framework right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有关 RIA 服务中的线路呼叫的作用和作用的详细信息非常复杂。如果您想获得有关此处发生的情况的详细答案,您最好在 RIA 上提问。服务论坛
但是,您有点违背 RIA 服务的设计。如果要返回对象集合,则应使用 Query 而不是 Invoke。
我只是凭空想象了一下,所以可能会有一些小错误。但这是一般的想法。
The details on what does and does not work for calls across the wire in RIA Services are complex. If you want a detailed answer on what is going on here, you'll have better luck asking on the RIA Services forum
However, you're kind of going against the design of RIA Services. If you want to return a collection of objects, you should use Query instead of Invoke.
I just did that off the top of my head so might have some minor errors. But that's the general idea.
我有一个你正在尝试的工作示例。您不需要更改您的域服务。确保您已安装 Visual Studio 2001 SP1,它还将 WCF RIA 更新到 SP1。
在您的 Silverlight 页面中,您可以按如下方式调用域服务:
I have a working example of what you are trying. You don't need to change your domain service. Ensure that you have installed Visual Studio 2001 SP1 which also updates WCF RIA to SP1.
In your Silverlight page you can call your domain service as follows: