簡體   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