I get an xml in my webAPI and deserializo it.
What I did, I got the exact template of the XML that I'm going to receive and I make a call on my service locally, just for the test effect. So long, I can get the fields I need. However, when I publish, in the documentation of who is going to send me, they inform that they will pass this same XML, but within a data parameter. I would like to know how to prepare my url to understand and capture the xml with this parameter. Until then, I make the request, sending via body, but I do not use it.
It will probably come with date = xml with content.
namespace WsCliMotoristas.Controllers
{
public class XmlController : ApiController
{
[HttpPost]
public void Post(HttpRequestMessage xml)
{
string idumov, identificadoralternativo;
idumov = "";
identificadoralternativo = "";
try
{
string body = xml.Content.ReadAsStringAsync().Result;
var Schedules = System.Xml.Linq.XDocument.Parse(body);
foreach (var elementos in Schedules.Root.Elements())
{
if (elementos.Name == "alternativeIdentifier")
{
identificadoralternativo = elementos.Value;
}
foreach (var historicos in elementos.Elements())
{
if (historicos.Name == "activityHistory")
{
idumov = historicos.FirstAttribute.Value;
}
}
}
GetEntrega entrega = new GetEntrega();
entrega.GeraEntregaAsync(idumov);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}