我想使用 Docusign Connect 服务,如 https://www.docusign.com/supportdocs/pdf/connect-guide.pdf 中所述.
我使用 Windows Communication Foundation 创建了一个 REST 服务来接受来自该服务的 POST 消息。接口(interface)类中两种不同方法的代码是:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "ProcessConnectMessageStream")]
string ProcessConnectMessageStream(Stream XMLMessage);
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "ProcessConnectMessageRequest")]
void ProcessConnectMessageRequest(HttpRequestMessage request);
方法的代码是:
public string ProcessConnectMessageStream(Stream XMLMessage)
{
StreamReader sr = new StreamReader(XMLMessage);
string xmlMessage = sr.ReadToEnd();
Manager mgr = new Manager();
return mgr.ProcessConnectMessage(xmlMessage);
}
和
public void ProcessConnectMessageRequest(HttpRequestMessage request)
{
try
{
// almost all code from https://github.com/docusign/recipe-010-webhook-csharp
XmlDocument xmldoc = new XmlDocument();
}
catch (Exception ex)
{
string msg = ex.GetBaseException().Message;
}
}
我设置了一个调用第一个方法的测试项目。我在连接指南的末尾保存了 XML(示例连接消息下的 XML)。我的测试方法获取文件并发布它。最后一个方法 mgr.ProcessConnectMessage(xmlMessage) 是我为解析 XML 而编写的。我的测试工作正常。我还创建了一个 GET 方法来确保服务正常运行。 GET 工作正常(我正在使用 ngrok 进行测试,因此我可以通过映射我的项目的 localhost:port 在互联网上调用我的 REST 方法)。
如第二种方法的评论中所述,我将第二种方法的代码基于我在 Github 上找到的内容,以创建 Docusign Connect 应该使用的方法。
我已在我的 Docusign 测试帐户上配置 Connect 以使用这些方法。我创建了信封并打开了它们。 Connect 将调用我的方法,如 NGROK 的输出所示。
但是无论调用哪种方法,我都会收到 400 Bad Request 错误。
我不知道我还应该做些什么来让 Connect 与我的方法进行通信。
最佳答案
请参阅我的最终评论。所以,我至少需要 30 个字符才能发布。
关于c# - 如何在 C# 中创建 REST Web 服务来处理 Docusign Connect 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49019920/