【问题标题】:System.Runtime.Serialization.InvalidDataContractException: when calling docusign apiSystem.Runtime.Serialization.InvalidDataContractException:调用docusign api时
【发布时间】:2014-05-10 03:07:04
【问题描述】:

在 CRM Online 上运行的插件中调用 Docusign API 时出现以下错误。

System.Runtime.Serialization.InvalidDataContractException:

键入“System.Threading.Tasks.Task`1[DocuSignIntegration.Plugins.DocuSignAPI.Envelope]” 不能序列化。考虑使用 DataContractAttribute 属性对其进行标记, 并使用 DataMemberAttribute 标记您想要序列化的所有成员 属性。如果类型是集合,请考虑使用 集合数据合同属性。请参阅 Microsoft .NET Framework 文档以了解 其他支持的类型。

代码如下:

        EnvelopeInformation envelopeInfo = new EnvelopeInformation();
        envelopeInfo.AccountId = _accountId;
        envelopeInfo.Subject = "My Subject";
        envelopeInfo.EmailBlurb = "My email blurb.";

        tracing.Trace("Enter using...");
        using (var scope = new System.ServiceModel.OperationContextScope(_apiClient.InnerChannel))
        {
            tracing.Trace("httpRequestProperty");

它在“using (var scope...”) 行抛出错误。

我在网上找到的帮助建议对服务进行更改,这当然无助于解决这个问题。有人有什么想法吗?

【问题讨论】:

    标签: c# docusignapi


    【解决方案1】:

    您正在配置的 DataContract 很可能存在问题,因为我可以使用 DocuSign SOAP SDK up on GitHub 很好地进行 SOAP API 调用。该项目可能对您有所帮助,因为您可以将其用作示例(因为它可以开箱即用)并且具有 .NETJavaPHPSalesforceRuby 的示例项目。

    使用该项目比较 ServiceModel 和 DataContracts 的设置方式,也可以查看您的设置可能在哪里。我还建议将您的代码包装在 try-catch 块中,以获取有关错误的更多信息。类似的东西:

    try
        {
            EnvelopeInformation envelopeInfo = new EnvelopeInformation();
            envelopeInfo.AccountId = _accountId;
            envelopeInfo.Subject = "My Subject";
            envelopeInfo.EmailBlurb = "My email blurb.";
    
            tracing.Trace("Enter using...");
            using (var scope = new System.ServiceModel.OperationContextScope(_apiClient.InnerChannel))
            {
                tracing.Trace("httpRequestProperty");
    
                // ... remaining code ...
            }
        }
    
        // Catch the InvalidDataContractException here. 
        catch(InvalidDataContractException iExc)
        {
            Console.WriteLine("You have an invalid data contract: ");
            Console.WriteLine(iExc.Message);
            Console.ReadLine();
        }
          catch (Exception exc)
        {
            Console.WriteLine(exc.Message);
            Console.WriteLine(exc.ToString() );
            Console.ReadLine();
        }
    

    【讨论】:

      猜你喜欢
      • 2021-07-07
      • 2020-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多