none
Erro com retornos JSON RRS feed

  • Pergunta

  • Implementei meu servidor para retornar em JSON, mas está dando um erro:

    [ServiceContract]
        public interface IBanco
        {
            [OperationContract]
            [WebInvoke(Method = "POST", UriTemplate = "/InsertBancos", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            void InsertBancos(Bancos model);
    
            [OperationContract]
            [WebInvoke(Method = "POST", UriTemplate = "/UpdateBancos", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            void UpdateBancos(Bancos model);
    
            [OperationContract]
            [WebInvoke(Method = "DELETE", UriTemplate = "/DeleteBancoPorID/{Id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            void DeleteBancoPorID(string Id);
    
            [OperationContract]
            [WebGet(UriTemplate = "/RetornarBancoPorId/{Id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            Bancos RetornarBancoPorId(string Id);
    
            [OperationContract]
            [WebGet(UriTemplate = "/RetornarTodosBanco", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            IList<Bancos> RetornarTodosBanco();
    
            [OperationContract]
            [WebGet(UriTemplate = "/RetornarTodosBancoPorFiltros/{filtro}/{criterio}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            IList<Bancos> RetornarTodosBancoPorFiltros(string filtro, string criterio);
    
            [OperationContract]
            [WebInvoke(Method = "POST", UriTemplate = "/RegistroDuplicadoBanco/{Campo}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            bool RegistroDuplicadoBanco(string Campo);
        }
    
    
    [ServiceContract]
        public interface IEstado
        {
    
            [OperationContract]
            [WebGet(UriTemplate = "/RetornarTodosEstados", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            IList<Estado> RetornarTodosEstados();
    
        }

    <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
    
        <!-- Configurações para o retorno json -->
        <services>
          <service name="Service.WinErpService">
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndBehave" contract="Service.Interfaces.IEstado"/>
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndBehave" contract="Service.Interfaces.IBanco"/>       
          </service>
        </services>
        
        <behaviors>
    
          <!-- Configurações para o retorno json -->
          <endpointBehaviors>
            <behavior name="EndBehave">
              <webHttp />
            </behavior>
          </endpointBehaviors>
          

    este é o erro que dá, isso acontece se no webconfig os endpoint estiver usando apenas um o IBanco por exemplo não dá erro funciona normal, mas preciso usar mais de um:

    Request Error

    The server encountered an error processing the request. The exception message is 'Multiple filters matched.'. See server logs for more details. The exception stack trace is:

    at System.ServiceModel.Dispatcher.EndpointDispatcherTable.LookupInCache(Message message, Boolean& addressMatched) at System.ServiceModel.Dispatcher.EndpointDispatcherTable.Lookup(Message message, Boolean& addressMatched) at System.ServiceModel.Dispatcher.ChannelHandler.GetDatagramChannel(Message message, EndpointDispatcher& endpoint, Boolean& addressMatched) at System.ServiceModel.Dispatcher.ChannelHandler.EnsureChannelAndEndpoint(RequestContext request) at System.ServiceModel.Dispatcher.ChannelHandler.TryRetrievingInstanceContext(RequestContext request)

    quinta-feira, 22 de novembro de 2012 10:16