Sharepoint hosted Restful WCF - Configure AutoMapper RRS feed

  • Question

  • We are using SharePoint 2016. And I am trying to build a wrapper Restful service for our existing WCF. After some research I identified SharePoint Hosted WCF services is the best approach as it can be used without adding a separate authentication module.

    I have a service proxy class in my WCF service. Which will return the Results calling the existing WCF. I am trying directly to return the object which I receive from the WCF result. But Without any error It failed. I think as the auto generated WCF proxy classes does not have [DataContract] and [DataMember] attributes there is a failure in serializing the result in to a JSON.

    After that I tried to Map to a separate data contract classes using auto Mapper. 

    var config = new MapperConfiguration(cfg =>
       cfg.CreateMap<Person, PersonDTO>();
    IMapper mapper = config.CreateMapper();       
    var dest = mapper.Map<Person,PersonDTO>(result);

    But once I add this in WCF method it fails to load even. Could anyone help me to resolve this. Or Is there a way I can directly pass the WCF result i get from the Old service result as a Json.

    Thank you.

    Friday, January 17, 2020 6:46 AM


All replies