问题描述
我们已经在应用程序中实现了docusign api,并且在开发环境中和一台生产服务器上都可以正常运行,但是在特定的生产服务器上,运行以下代码行就会失败
We've implement docusign api into our application and it works fine in development and on one of our production servers, but on particular production server it fails when running the following line
var scope = new OperationContextScope(client.InnerChannel);
var scope = new OperationContextScope(client.InnerChannel);
抛出的异常是
错误: InvalidDataContractException:消息:类型'System.Threading.Tasks.Task`1 [DocuSign.DocuSignWeb.SetSharedAccessResult]'无法序列化。考虑使用DataContractAttribute属性标记它,并使用DataMemberAttribute属性标记要序列化的所有成员。如果类型是集合,请考虑使用CollectionDataContractAttribute对其进行标记。有关其他受支持的类型,请参见Microsoft .NET Framework文档。
Error: InvalidDataContractException: Message: Type 'System.Threading.Tasks.Task`1[DocuSign.DocuSignWeb.SetSharedAccessResult]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
此处是称为的完整方法
public DocuSignResponse SendEnvelope(Envelope envelope, string templateGUID)
{
var response = new DocuSignResponse();
var client = new DSAPIServiceSoapClient("DSAPIServiceSoap", URL);
try
{
var scope = new OperationContextScope(client.InnerChannel);
{
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("X-DocuSign-Authentication", AuthHeader);
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
if (client.InnerChannel.State != System.ServiceModel.CommunicationState.Faulted)
{
// call service - everything's fine
}
else
{
// channel faulted - re-create your client and then try again
response.Success = false;
response.ErrorMessage = "Channel has faulted!!";
return response;
}
client.Open();
EnvelopeStatus envelopeStatus;
if (!string.IsNullOrEmpty(templateGUID))
{
DocuSignWeb.EnvelopeInformation envelopeInfo = new DocuSignWeb.EnvelopeInformation();
envelopeInfo.AccountId = AccountId;
envelopeInfo.EmailBlurb = envelope.EmailBlurb;
envelopeInfo.Subject = envelope.Subject;
// Configure the inline templates
DocuSignWeb.InlineTemplate inlineTemplate = new DocuSignWeb.InlineTemplate();
inlineTemplate.Sequence = "1";
inlineTemplate.Envelope = new DocuSignWeb.Envelope();
inlineTemplate.Envelope.Recipients = envelope.Recipients;
inlineTemplate.Envelope.AccountId = AccountId;
DocuSignWeb.CompositeTemplate template = new DocuSignWeb.CompositeTemplate();
template.InlineTemplates = new DocuSignWeb.InlineTemplate[] {inlineTemplate};
DocuSignWeb.ServerTemplate serverTemplate = new DocuSignWeb.ServerTemplate();
serverTemplate.Sequence = "1";
serverTemplate.TemplateID = templateGUID;
template.ServerTemplates = new[] {serverTemplate};
template.Document = envelope.Documents[0];
envelopeStatus = client.CreateEnvelopeFromTemplatesAndForms(envelopeInfo, new[] {template}, true);
}
else
{
envelopeStatus = client.CreateAndSendEnvelope(envelope);
}
// An envelope ID indicates that it succeeded
response.Success = true;
response.ResponseRef = envelopeStatus.EnvelopeID;
// No point doing this, as it wouldn't have been signed
// Request the status of that envelope
// response.Status = client.RequestStatus(envelopeStatus.EnvelopeID);
// Used if embed option being used
response.Envelope = envelope;
response.Status = envelopeStatus;
if (client.State != CommunicationState.Faulted)
{
client.Close();
}
else
{
client.Abort();
}
}
}
catch (InvalidDataContractException err)
{
err.LogError();
response.Success = false;
response.ErrorMessage = string.Format("InvalidDataContractException: Message: {0} StackTrace: {1} AuthHeader: {2}", err.Message, err.StackTrace, AuthHeader);
}
catch (CommunicationException err)
{
err.LogError();
response.Success = false;
response.ErrorMessage = string.Format("CommunicationException: Message: {0} StackTrace: {1}", err.Message, err.StackTrace);
client.Abort();
}
catch (TimeoutException err)
{
err.LogError();
response.Success = false;
response.ErrorMessage = string.Format("TimeoutException: Message: {0} StackTrace: {1}", err.Message, err.StackTrace);
client.Abort();
}
catch (Exception err)
{
err.LogError();
response.Success = false;
response.ErrorMessage = string.Format("Exception: Message: {0} StackTrace: {1}", err.Message, err.StackTrace);
client.Abort();
}
finally
{
client = null;
}
return response;
}
此刻,我对问题所在不知所措,鉴于相同的代码和数据库可以在另一台机器上运行,因此目前认为它是环境。
At the moment i'm at a loss as to what the issue is, given the same code and database works on another machines, so at present thinking it's environmental.
任何帮助都将不胜感激。
Any help greatly appreciated.
推荐答案
事实证明,这似乎是DocuSign方面的服务器问题。有时在DocuSign的Demo沙箱环境中会出现一些错误和其他问题。
Looks like this turned out to be server issues on DocuSign side. Occasionally there are bugs and other issues that get rolled back in DocuSign's Demo sandbox environment.
这篇关于Docusign .net在一台服务器上发送信封问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!