相关疑难解决方法(0)

为什么我的WCF Web服务在具有不同字段名称的不同命名空间中呈现此对象?

上下文:我正在尝试与DocuSign的Connect通知服务集成.我已经使用一个名为DocuSignConnectUpdate的方法设置了一个WCF服务,该方法将DocuSignEnvelopeInformation作为其唯一参数,由DocuSign指定.这个DocuSignEnvelopeInformation对象来自对它们的API的引用,因此它们可以将此对象传递给我的Web服务,并且我确切地知道会发生什么.DocuSign要求我在他们的网站上配置我的服务地址和命名空间.

问题: DocuSign发送的XML就是我所期望的.DocuSignEnvelopeInformation及其子节点位于名称空间" http://www.docusign.net/API/3.0 "中,元素名称与对象名称匹配:

<DocuSignEnvelopeInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.net/API/3.0">
    <EnvelopeStatus>...</EnvelopeStatus>
</DocuSignEnvelopeInformation>
Run Code Online (Sandbox Code Playgroud)

但我的Web服务期望在错误的命名空间中使用不同的东西,并使用修改后的元素名称.这就是我的WSDL中定义DocuSignConnectUpdate方法的方法:

<xs:element name="DocuSignConnectUpdate">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="DocuSignEnvelopeInformation" nillable="true" type="tns:DocuSignEnvelopeInformation"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)

这就是我在WSDL中定义DocuSignEnvelopeInformation类型的方式:

<xs:complexType name="DocuSignEnvelopeInformation">
    <xs:sequence>
        <xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/System.ComponentModel" name="PropertyChanged" nillable="true" type="q1:PropertyChangedEventHandler"/>
        <xs:element name="documentPDFsField" nillable="true" type="tns:ArrayOfDocumentPDF"/>
        <xs:element name="envelopeStatusField" nillable="true" type="tns:EnvelopeStatus"/>
        <xs:element name="timeZoneField" nillable="true" type="xs:string"/>
        <xs:element name="timeZoneOffsetField" type="xs:int"/>
        <xs:element name="timeZoneOffsetFieldSpecified" type="xs:boolean"/>
    </xs:sequence>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)

像envelopeStatusField这样的元素名称是自动生成的代码中使用的私有变量的名称.公共属性名称与DocuSign发送的xml相匹配.自动生成的代码还使用XmlTypeAttribute使用正确的docusign命名空间标记每个对象.因此,通过查看自动生成的代码,我希望我的服务对输入感到满意,但生成的WSDL是不同的,如上所示,我的服务无法反序列化xml.

一些代码: DocuSignEnvelopeInformation的自动生成声明:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.docusign.net/API/3.0")]
public partial class DocuSignEnvelopeInformation : object, System.ComponentModel.INotifyPropertyChanged {

    private EnvelopeStatus envelopeStatusField;

    private DocumentPDF[] …
Run Code Online (Sandbox Code Playgroud)

wcf web-services xml-namespaces docusignapi

3
推荐指数
1
解决办法
3638
查看次数

标签 统计

docusignapi ×1

wcf ×1

web-services ×1

xml-namespaces ×1