WCF服务无法反序列化XML请求,因为命名空间属性位于根XML节点上
我目前正在向现有的WCF服务添加一个新的端点,以从DocuSign接收web钩子通知 该方法需要一个类型为DocuSignEnvelopeInformation的单一参数,该参数是在DocuSign API中定义的一个类,我将其添加为服务引用 来自DocuSign的XML请求正在使用命名空间“” 实现非常简单 接口:WCF服务无法反序列化XML请求,因为命名空间属性位于根XML节点上,xml,rest,wcf,docusignapi,Xml,Rest,Wcf,Docusignapi,我目前正在向现有的WCF服务添加一个新的端点,以从DocuSign接收web钩子通知 该方法需要一个类型为DocuSignEnvelopeInformation的单一参数,该参数是在DocuSign API中定义的一个类,我将其添加为服务引用 来自DocuSign的XML请求正在使用命名空间“” 实现非常简单 接口: [ServiceContract(Namespace = "http://www.docusign.net/API/3.0")] public interface IDocuSig
[ServiceContract(Namespace = "http://www.docusign.net/API/3.0")]
public interface IDocuSignEventListener
{
[OperationContract]
[XmlSerializerFormat]
string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation);
}
控制器:
[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;
}
}
当我运行服务并访问端点的帮助页面时,我看到以下内容是预期的请求:
如您所见,namespace属性不在根节点上
但是,DocuSign正在发送以下XML,其命名空间位于根节点上:
服务为此请求返回400错误,但出现以下异常:
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.
如果我手动编辑请求主体并将名称空间移动到EnvelopeStatus节点,这一切都会很好地工作,但显然我无法在生产环境中控制请求的格式
我不明白为什么服务需要内部节点上的名称空间声明,特别是考虑到DocuSignEnvelopeInformation对象是直接从docusignapi引用的
非常感谢您的指导。我的同事在使用C#中的LINQ解码XML时遇到了一个相关问题。她通过在对每个属性的引用中包含xmlns(XML名称空间)字符串来解决这个问题 显然,这是对xmlns属性的严格解释
您是否在SOAP模式下使用Connect?这可能会有帮助 我的同事在使用C#中的LINQ解码XML时遇到了一个相关问题。她通过在对每个属性的引用中包含xmlns(XML名称空间)字符串来解决这个问题 显然,这是对xmlns属性的严格解释 您是否在SOAP模式下使用Connect?这可能会有帮助