Question

I have created a WFC RIA Service based on ASP.Net Website and adding the nuget packages for RIA service. I have also created a Service named "FactoryService" by extending DomainService class.

I have tested the service by creating a GridView with DomainDataSource pointing to the service. The service is working.

Now I want to access the service from other clients as I have enabled SOAP endpoint. But I cannot find the service's url to the svc file. I need this url to add service reference to my other projects. How do I find the service url?

I have tried the following urls and all returns 404. (namespace "WebApplication3", DomainService class "FactoryService").

 - http://localhost:15066/WebApplication3-FactoryService.svc
 - http://localhost:15066/services/WebApplication3-FactoryService.svc
 - http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc
 - http://localhost:15066/FactoryService.svc
 - http://localhost:15066/services/FactoryService.svc
 - http://localhost:15066/ClientBin/FactoryService.svc
Was it helpful?

Solution

I have found the problem. In the DomainService class, I missed to annotate it with [EnableClientAccess()].

A domain service class must be marked with the EnableClientAccessAttribute attribute to make the service available to the client project. The EnableClientAccessAttribute attribute is automatically applied to a domain service when you select the Enable client access check box in the Add New Domain Service Class dialog box.

As I'm using VS2013, the wizard is not available and missed to annotate it with the attribute.

OTHER TIPS

Normally it has the following form

Base-Address + ClientBin + FullName of DomainService (Namespace+TypeName separated by -) So in your case it should look like

http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc

When you access this link in a Browser you will be provided a page that looks similar to this

Service

You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:


svcutil.exe http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc?wsdl
You can also access the service description as a single file:

http://localhost:15066/ClientBin/WebApplication3-FactoryService.svc?singleWsdl
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:

C#

class Test
{
    static void Main()
    {
        HelloClient client = new HelloClient();

        // Use the 'client' variable to call operations on the service.

        // Always close the client.
        client.Close();
    }
}

Visual Basic

Class Test
    Shared Sub Main()
        Dim client As HelloClient = New HelloClient()
        ' Use the 'client' variable to call operations on the service.

        ' Always close the client.
        client.Close()
    End Sub
End Class
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top