Member
53 Points
246 Posts
Sep 21, 2019 06:33 AM|mywatermelon|LINK
Hi, now I need to get the body from a post. Here is the code:
public string GetMsg([FromBody]xml x) { return ""; } public class xml { public string ToUserName { get; set; } public string FromUserName { get; set; } public string CreateTime { get; set; } public string MsgType { get; set; } public string Content { get; set; } public string MsgId { get; set; } }
These codes work well.
However, the remote server will post several XML to my server with the same parent node but different child nodes for different functions.
For example:
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>1348831860</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[this is a test]]></Content> <MsgId>1234567890123456</MsgId> </xml>
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>1357290913</CreateTime> <MsgType><![CDATA[voice]]></MsgType> <MediaId><![CDATA[media_id]]></MediaId> <Format><![CDATA[Format]]></Format> <MsgId>1234567890123456</MsgId> </xml>
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>1357290913</CreateTime> <MsgType><![CDATA[video]]></MsgType> <MediaId><![CDATA[media_id]]></MediaId> <ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId> <MsgId>1234567890123456</MsgId> </xml>
I can only define one 'xml' class in a cs file, now it seems I have to create many cs file and define the 'xml' class in each of them.
It is so troublesome. And also, I can change the code of the remote server.
How can I deal with this? Thank you.
Member
53 Points
246 Posts
How can I get body from a post with the same parent node but different child node?
Sep 21, 2019 06:33 AM|mywatermelon|LINK
Hi, now I need to get the body from a post. Here is the code:
These codes work well.
However, the remote server will post several XML to my server with the same parent node but different child nodes for different functions.
For example:
I can only define one 'xml' class in a cs file, now it seems I have to create many cs file and define the 'xml' class in each of them.
It is so troublesome. And also, I can change the code of the remote server.
How can I deal with this? Thank you.