WCF RIA Services DomainService error: ContractDescription has zero operations; a contract must have at least one operation

StackOverflow https://stackoverflow.com/questions/20453984

  •  30-08-2022
  •  | 
  •  

Pregunta

I am developing a small instant messaging application that makes use of few DomainServices on the server side. Trying to access the domain service URL, I encounter the following error:

"ContractDescription 'AppInitService' has zero operations; a contract must have at least one operation".

The domain service Url is this one: http://givemeword.net/chat/Services/IM-Chat-UI-Web-DomainServices-AppInitService.svc

You can find the domain service class below:

namespace Chat.UI.Web.DomainServices
{
    [EnableClientAccess()]
    public class AppInitService : DomainService
    {
        private System.Security.Principal.IPrincipal _user;
        private readonly Chat.UI.Web.Services.AppInitService _appInitService;

        public AppInitService()
        {
            _appInitService = new Chat.UI.Web.Services.AppInitService();
        }

        public InitUserSettingsDTO InitUserSettings(Guid userId)
        {
            var initUserSettingsDTO = new InitUserSettingsDTO();

            return initUserSettingsDTO;
        }
    }
}

As you can see, I am using a complex type as the return type of the only function of the domain service.

What I can not figure out is why on my testing Windows Server 2012 (not a development machine, just a virtual machine used for testing) or on my development machine everything runs without any problem, but on the hosting account it raise the error above.

Does anyone has any idea about this?

Thank you

¿Fue útil?

Solución

Try adding the [Invoke] attribute to your InitUserSettings method:

    [Invoke]
    public InitUserSettingsDTO InitUserSettings(Guid userId)
    {
        var initUserSettingsDTO = new InitUserSettingsDTO();

        return initUserSettingsDTO;
    }

Make sure your web.config is set up as described here: http://msdn.microsoft.com/en-us/library/ff426912(v=vs.91).aspx

Otros consejos

Being exasperated with this strange situation and the low support I received from the web hosting company, I have tried the same thing with another web provider. As I was thinking, it was working this time with no problems, so my assumption that the original provider had poor support for WCF RIA Services (or maybe other unidentified problem) was correct.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top