1
votes

I'm currently adding a new end point to an existing WCF service to receive web-hook notifications from DocuSign.

The method is expecting a single parameter of type DocuSignEnvelopeInformation which is a class defined in the DocuSign API which I have added as a service reference.

The XML request from DocuSign is using the namespace "http://www.docusign.net/API/3.0".

The implementation is very simple.

Interface:

[ServiceContract(Namespace = "http://www.docusign.net/API/3.0")]
public interface IDocuSignEventListener
{
    [OperationContract]
    [XmlSerializerFormat]
    string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation);
}

Controller:

[ServiceBehavior(Namespace = "http://www.docusign.net/API/3.0")]
public class DocuSignEventService : IDocuSignEventListener
{
    [OperationBehavior]
    public string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation)
    {
        // process the notification

        return DocuSignEnvelopeInformation.EnvelopeStatus.EnvelopeID;
    }

}

When I run the service and visit the help page for the end point I see the following as the expected request:

Expected XML request format

As you can see the namespace attribute is not on the root node.

However DocuSign are sending the following XML with the namespace is on the root node:

DocuSign XML Body

The service is returning a 400 error for this request with the following exception:

Unable to deserialize XML body with root name 'DocuSignEnvelopeInformation'
and root namespace 'http://www.docusign.net/API/3.0' (for operation
'DocuSignConnectUpdate' and contract ('IDocuSignEventListener',  'http://www.docusign.net/API/3.0'))
using XmlSerializer. Ensure that the type corresponding to the XML is added to the known types collection
of the service.

If I manually edit the request body and move the namespace to the EnvelopeStatus node it all works perfectly, but obviously I can't control the format of the request in production.

I can't figure out why the service is expecting the namespace declaration on the inner node, particularly considering the DocuSignEnvelopeInformation object is referenced directly from the the DocuSign API.

Any guidance is greatly appreciated.

1

1 Answers

0
votes

My colleague just ran into a related issue while using LINQ in C# to decode the XML. She solved it by including the xmlns (XML Name Space) string in her references to each of the attributes.

Apparently that's the strict interpretation of the xmlns attribute.

Are you using Connect in SOAP mode? That may help.