So I have the following issue:
We have a scenario where a third party is sending post messages to our server, we have no control over that, and they want to send everything to a single url, so we can not do anything regarding query parameters, so my question then is, is it possible to handle different post messages with a single action. In essence the content of the post message will define what needs to happen with said request.
Post message 1:
<xml>
<content1> content </content1>
<content2> content </content2>
</xml>
Post message 2:
<xml>
<content1> content </content1>
<content3> content </content3>
</xml>
As you can see some of the messages will have similar properties.
Thanks
You can use the following signature to accept arbitrary XML content,
public HttpResponseMessage Post([FromBody]XElement xmlbody) {
// Process the xmlbody
return new HttpResponseMessage(HttpStatusCode.Created);
}
I have more details about this kind of raw media type processing here .
It is possible. Specify your action to have a string input parametre. That way you can get the entire message as a string and not worry about its properties... However, you will need to implement the logic in the controller to diferentiate messages.
[HttpPost]
public ActionResult MyActionForAllMessages(string message)
{
//Your logic
}
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.