How to return values in a WCF web service

0

I'm doing this web method, and everything is fine until the moment when it will return the data, "It does not show them" and I do not know what is wrong with me. The controller works, the Repository works, the SP works, the matter is at the time of returning the data.

 [WebInvoke(Method = "Get", BodyStyle = WebMessageBodyStyle.Wrapped, 
  ResponseFormat = WebMessageFormat.Xml)]
  [OperationBehavior]
    public ResultadoOperacionConValor<TarjetaHabiente> 
  TarjetahabienteCargarPorCedulaNacionalidadyCliente(int cedula, int nacionalidad, int clienteID)
     {
         var resultado = new ResultadoOperacionConValor<TarjetaHabiente> { Estatus = EstatusOperacion.OperacionExitosa };
       try
       {

           resultado.Valor = _controladorTarjetahabiente.TarjetahabientesCargar(cedula, nacionalidad, clienteID);

       }
       catch (Exception ex)
       {
           Notificador.LogError(ErrorTipo.ErrorMetodoWeb, ex, "");
           return new ResultadoOperacionConValor<TarjetaHabiente>(EstatusOperacion.OperacionNoSoportada, Excepciones.ErrorMetodoAplicacion);
       }

       return resultado;

   }
    
asked by keiver vasquez 11.12.2018 в 21:07
source

1 answer

1

Solution.

In your class that you perform to return the values, put [DataMenber]

and now if you rerun.

 [WebInvoke(Method = "Get", BodyStyle = WebMessageBodyStyle.Wrapped, 
  ResponseFormat = WebMessageFormat.Xml)]
  [OperationBehavior]
    public ResultadoOperacionConValor<TarjetaHabiente> 
  TarjetahabienteCargarPorCedulaNacionalidadyCliente(int cedula, int nacionalidad, int clienteID)
     {
         var resultado = new ResultadoOperacionConValor<TarjetaHabiente> { Estatus = EstatusOperacion.OperacionExitosa };
       try
       {

           resultado.Valor = _controladorTarjetahabiente.TarjetahabientesCargar(cedula, nacionalidad, clienteID);

       }
       catch (Exception ex)
       {
           Notificador.LogError(ErrorTipo.ErrorMetodoWeb, ex, "");
           return new ResultadoOperacionConValor<TarjetaHabiente>(EstatusOperacion.OperacionNoSoportada, Excepciones.ErrorMetodoAplicacion);
       }

       return resultado;

   }
    
answered by 11.12.2018 / 22:10
source