views:

91

answers:

1

I have used the SL business application template and added a new blank, empty domain service in my Services folder on the .Web part of the solution. The class is DomainService1 and inherits from DomainService. It contains one method:

public class DomainService1 : DomainService
{
    public string Hello()
    {
        return "Hello World";
    }
}

How do I access this service method from the client? I can't seem to create an instance of the domain service at all client side.....

+2  A: 

The client side code is generated by RIA Services.

To access services that inherits DomainService you create a new context on the client side.

Replace the "Service" part of the name with "Context".

UserService = UserContext, ArticleService = ArticleContext etc.

Client code

var testContext = new TestContext();
            testContext.Hello();

Service code

[EnableClientAccess]
    public class TestService : DomainService
    {
        public string Hello()
        {
            return "Hello world!";
        }
    }
Einarsson
My god you are right!
Calanus