DocuSign Connect Listener MVC5 Api

时间:2016-01-28 21:05:17

标签: asp.net-mvc docusignapi

我有以下MVC 5 Rest Controller:

org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class data.CarDetails] from JSON String; no single-String constructor/factory method (through reference chain: data.PropertyLedger["carList"])

但是,当我转到DocuSign Connect设置并尝试发送时,我得到的只是:

namespace Rest4.Controllers
{
    public class DocuSignController : ApiController
    {
        // POST api/docusign
        public void Post([FromBody]DocuSignAPI.DocuSignEnvelopeInformation DocuSignEnvelopeInformation)
        {
            try
            {
                System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(DocuSignAPI.DocuSignEnvelopeInformation));
                XmlSerializer serializer = new XmlSerializer(typeof(DocuSignAPI.DocuSignEnvelopeInformation));
                StringBuilder sb = new StringBuilder();
                using (StringWriter writer = new StringWriter(sb))
                {
                    serializer.Serialize(writer, DocuSignEnvelopeInformation);
                }
                string fileName = DateTime.Now.Ticks.ToString();
                using (StreamWriter outputFile = new StreamWriter(string.Format(@"c:\clientuploads\{0}.xml", fileName)))
                {
outputFile.WriteLine(sb.ToString());
outputFile.WriteLine("Nothing to see here");
}
            }
            catch { }
        }

但是,如果我查看DocuSign网站上的日志:

<?xml version="1.0" encoding="utf-16"?>
<DocuSignEnvelopeInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" />
Nothing to see here

那么,为什么我从DocuSign获得的文件是空的?有没有更好的方法来捕获信息?如果我尝试使用1/28/2016 8:49:56 PM Connect send to: http://somewhere.com/Rest/api/DocuSign 1/28/2016 8:49:56 PM Envelope Data (documents were included):<?xml version="1.0" encoding="utf-8"?><DocuSignEnvelopeInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.net/API/3.0"><EnvelopeStatus><RecipientStatuses><RecipientStatus><Type>Signer</Type><Email>someemailaddress</Email><UserName>somebody</UserName><RoutingOrder>1</RoutingOrder><Sent>2016-01-13T10:35:11.16</Sent>....<Sequence>4</Sequence></DocumentStatus></DocumentStatuses></EnvelopeStatus></DocuSignEnvelopeInformation> ,我会在DocuSign网站上收到500错误

1 个答案:

答案 0 :(得分:0)

在初始化序列化程序时是否指定了默认名称空间,如下所示。

 XmlSerializer serializer = new XmlSerializer(typeof(DocuSignEnvelopeInformation), "http://www.docusign.net/API/3.0");
 DocuSignEnvelopeInformation envelopeInfo = serializer.Deserialize(reader) as DocuSignEnvelopeInformation;