简体   繁体   中英

Can we use azure functions for an incoming XML post

I am new to azure and trying to learn about azure functions, I implemented a HTTP Trigger function where it receives Json as a payload and converts the body content Json to a string and then using Json deserializer into a POCO object and puts the object into a output queue using outputBinding. I would like to know 1) Can we have an xml post req to our azure function. 2) If so, I would like send the body content(XML) as an xml (I dont want xml to be converted to string) to the output Queue.

Thanks in advance.

Since functions are merely HTTP listeners which accept HTTP POSTs, you can most certainly accept a POST containing XML content. I'm not sure what you're after by trying to avoid converting XML to a string, since the input to the function is a stream of bytes representing an HTTP request - a string.

I'm not sure why you'd want to introduce the overhead of loading into an XML document, but here is an example of how you could do it:

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    string body = await req.Content.ReadAsStringAsync();    
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(body);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM