繁体   English   中英

从HTTP Post C#捕获XML

[英]Capture XML from HTTP Post C#

因此,我开始研究DocuSign的webhooks实现。 我需要从HTTP帖子(文档连接)接受Web API(C#)中的XML,然后将数据发送到SQL Server。主要问题是XML有很多子级,我不确定如何将其映射到一个模型。 我一直在不懈地寻找一种解决方案,以便在Post控制器中接受XML,然后将其发送到SQL表,但是没有找到任何可行的方法。 任何指导将不胜感激。

这是XML的示例

<DocuSignEnvelopeInformation>
<EnvelopeStatus>
<RecipientStatuses>
<RecipientStatus>
<Type>Signer</Type>
<Email>user@user.com</Email>
<UserName>test user</UserName>
<RoutingOrder>1</RoutingOrder>
<Sent>2018-03-05T10:44:06.443</Sent>
<Delivered>2018-03-05T10:45:22.443</Delivered>
<Signed>2018-03-05T10:45:24.413</Signed>
<DeclineReason/>
<Status>Completed</Status>
<RecipientIPAddress>00.00.00.00</RecipientIPAddress>
<RecipientId>aa923fgf2-e59d-45df-8447-8e55437b6cf7</RecipientId>
</RecipientStatus>
</RecipientStatuses>
<TimeGenerated>2018-03-05T10:45:42.6635679</TimeGenerated>
<EnvelopeID>3034gfdfd3-e6c3-4dsg6-af18-252f8fdsf3b5</EnvelopeID>
<Subject>Testing Webhooks DocuSign</Subject>
<Created>2018-03-05T10:42:59.24</Created>
<Sent>2018-03-05T10:45:25.617</Sent>
</EnvelopeStatus>
</DocuSignEnvelopeInformation>

using System.Web.Http;

namespace DocuSignAPI.Controllers
{
    public class DocuSignEnvelopeController : ApiController
    {
        [HttpPost]
        public void Post([FromBody]  Models.EnvelopeStatus envelope, Models.RecipientStatus status, Models.RecipientStatuses statuses, Models.DocuSignEnvelopeInformation info)
        {


        }
    }
}

模型生成器生成模型类,然后可以继续前进。

DocuSignEnvelopeInformation是您的根对象,所有传入数据都将包装在该签出代码中

namespace DocuSignAPI.Controllers
{
    public class DocuSignEnvelopeController : ApiController
    {
        [HttpPost]
        public void Post(Models.DocuSignEnvelopeInformation data)
        {

        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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