In Services, i m calling the endpoint service and got response as Future[] Result. I need to send the Future[] Result to Controllers. In Controllers i should respond the result via Ok(response).
//In Controllers i have to receive the response from Services and have to
send the success or failure response.
def postLead = Action.async { lead =>
val isSuccess = service.postToFreedom(lead).map{ response =>
Ok(response)
}
}
//In Services,i am hitting the end point service and got the response as Future[]
private def postToFreedom(postXML:Request): Future[WSResponse] = {
val leadXml = FreedomMortgageXML(postXML).toXml
val response = ws.url(serviceEndpoint).withHeaders("Content-Type" -> "application/xml").post(leadXml)
response.map { response =>
response
}
You need to convert your
ws.WSResponse
into amvc.Result
: