我使用Visual Studio的wsdl.exe创建基于https://www.docusign.net/api/3.0/api.asmx?wsdl的类文件。
代码很简单:
XmlSerializer serializer = new XmlSerializer(typeof(BusinessObjects.Docusign.DocuSignEnvelopeInformation));
StreamReader reader = new StreamReader(context.Request.GetBufferlessInputStream());
BusinessObjects.Docusign.DocuSignEnvelopeInformation envelopeStatus = (BusinessObjects.Docusign.DocuSignEnvelopeInformation)serializer.Deserialize(reader)
解串器正在证明这是出乎意料的:
<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">
答案 0 :(得分:0)
通过在实例化XmlSerializer
时声明默认命名空间来解决此问题 XmlSerializer serializer = new XmlSerializer(typeof(DocuSignEnvelopeInformation), "http://www.docusign.net/API/3.0");
将此装饰器添加到生成的DocuSignEnvelopeInformation类
[System.Xml.Serialization.XmlRoot (ElementName = "DocuSignEnvelopeInformation")]