Docusign Listener Argument Null开发沙箱

问题描述

我已经在C#网络服务中创建了一个网络方法,当信封状态更改时,该方法侦听Docusign调用


[WebMethod]

        public void DocuSignConnectUpdate(DocuSignEnvelopeinformation DocuSignEnvelopeinformation)
        {
            
            //Check if null
            if (DocuSignEnvelopeinformation == null)
            {
                File.WriteallText("C:\\websites\\DataAPI\\datalog.txt","Data: " + "Data is null");
            }
            else
            {
                string envelopeId = "";
                try
                {
                    //Write a line in a file
                    File.WriteallText("C:\\websites\\DataAPI\\datalog.txt","Data: " + DocuSignEnvelopeinformation.ToString());
     
                    //Get some data out
                    envelopeId = DocuSignEnvelopeinformation.Envelopestatus.EnvelopeID;

                    //Write Data to a file
                    File.WriteallText("C:\\websites\\DataAPI\\innerdatalog.txt","Data: " + DocuSignEnvelopeinformation.ToString());


                }
                catch (Exception ex)
                {
                    // Could not serialize
                    File.WriteallText("C:\\websites\\DataAPI\\errorlog.txt","Exception: " + ex.Message);
                    
                    throw new SoapException(ex.Message,SoapException.ClientFaultCode);
                }

                
            }

我遇到的问题是,调用时未设置DocuSignEnvelopeinformation参数,因此代码始终在if == null语句处终止。当我使用SoapUI将信封数据运行到API时,一切正常。任何我想念的想法都将不胜感激。

编辑:我也想在这里添加接口,因为我最初忘记了它

    [ServiceContract(ConfigurationName = "IOperations",Namespace = "https://www.docusign.net/API/3.0")]
    public interface IOperations
    {
        
        [OperationContract(Action = "DocuSignConnectListener/Operations/DocuSignConnectUpdate")]
        [XmlSerializerFormat]
        string DocuSignConnectUpdate(DocuSignEnvelopeinformation DocuSignEnvelopeinformation);
    }

解决方法

将DocuSign Webhook设置为使用SOAP模式时,该通知将作为SOAP请求发送到您的服务器(您的监听器)。

如果SOAP模式已关闭,则通知将作为常规POST请求发送,带有XML正文。

在您的问题中,您说

当我使用SoapUI将信封数据运行到API时,一切都会正常工作

所以听起来一切都按设计进行。

,

好吧,我终于弄清楚了,结果发现它还不够漂亮,所以我专门添加了装饰:

[SoapDocumentMethod("http://tempuri.org/DocuSignConnectUpdate",RequestNamespace = "http://tempuri.org",ResponseNamespace = "http://tempuri.org",Use = System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

在方法上,现在一切都按预期运行。现在,我看了,它变得更有意义了。