如何使用WEB API获取Get方法列表?使用依赖注入(SOA体系结构)

问题描述 投票:-1回答:1

我正在尝试使用WEB API返回一个人列表,但我没有成功。我正在使用依赖注入(SOA体系结构)

<Error>
<Message> Error. </ Message>
<ExceptionMessage>
The type 'ObjectContent`1' could not serialize the response body for the content type application / xml; set of characters = utf-8 '.
</ ExceptionMessage>
<ExceptionType> System.InvalidOperationException </ ExceptionType>
<StackTrace />
<InnerException>
<Message> Error. </ Message>

我的方法如下:

public class CuentaController : ApiController
{
    private IUsurioESContrato _servicePerson;
    public CuentaController()
    {
        _servicePerson = new UsuarioESImplementacion();
    }
    [HttpGet]       
    public IEnumerable GetListPersona()
    {
        PersonaModel model = new PersonaModel();
        model.ListPersona = _servicePerson.ListarPersonas();
         return model.ListPersona;
    }
api model-view-controller soa
1个回答
0
投票

它的工作方式与此类似,但其目的是使用模型

    public IEnumerable<Persona> GetListPersona()
    {
        return  _servicePerson.ListarPersonas().ToList();
    }

如何使用模型来实现方法而不调用主类?

© www.soinside.com 2019 - 2024. All rights reserved.