Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF反序列化包含多态对象的SOAP数组时出现问题_Wcf_Soap_Wsdl - Fatal编程技术网

WCF反序列化包含多态对象的SOAP数组时出现问题

WCF反序列化包含多态对象的SOAP数组时出现问题,wcf,soap,wsdl,Wcf,Soap,Wsdl,我对反序列化多态对象数组的WCF web服务有一个问题。服务器端不是WCF,但我从WSDL创建了存根。WSDL中的重要部分是 <complexType name="NodeList"> <sequence> <element name="data" type="cmtypes:Node" minOccurs="0" maxOccurs="unbounded" nillable="true"/> </sequence>

我对反序列化多态对象数组的WCF web服务有一个问题。服务器端不是WCF,但我从WSDL创建了存根。WSDL中的重要部分是

<complexType name="NodeList">
    <sequence>
        <element name="data" type="cmtypes:Node" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
    </sequence>
</complexType>
但是,如果我收到一条包含主节点的消息,如

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cmtypes="http://www.brightcomputing.com/cmtypes.xsd" xmlns:cmdevice="http://www.brightcomputing.com/cmdevice.wsdl">
    <s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope"></s:Header>
    <SOAP-ENV:Body>
        <cmdevice:getNodesResponse SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
            <nodes xsi:type="cmtypes:NodeList" xmlns="">
                <data xsi:type="cmtypes:MasterNode">
                    <uniqueKey xsi:type="xsd:unsignedLong">38654705666</uniqueKey>
                    <revision xsi:type="xsd:string"></revision>
                    <modified xsi:type="xsd:boolean">false</modified>
                    <toBeRemoved xsi:type="xsd:boolean">false</toBeRemoved>
[...]
但是,在我的回答中,我得到一个
节点列表
,它直接包含一系列
数据
元素,这些元素实际上是节点或从节点派生而来:

<cmdevice:getNodesResponse SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <nodes xsi:type="cmtypes:NodeList" xmlns="">
        <data xsi:type="cmtypes:MasterNode">
            <uniqueKey xsi:type="xsd:unsignedLong">38654705666</uniqueKey>

            [...]
        </data>
        <data xsi:type="cmtypes:PhysicalNode">
            <uniqueKey xsi:type="xsd:unsignedLong">38654705669</uniqueKey>
            [...]
        </data>
    [...]

38654705666
[...]
38654705669
[...]
[...]

你认为我可以通过在WCF中注入行为来解决这个问题吗?我最大的问题是,我完全不可能改变服务器端…

对此进行故障排除将非常困难。我要尝试的一件事是使用它来查看它是否可以反序列化,然后开始减少消息,直到您得到有问题的类型。

哪里有cmtypes的定义:NetworkInterfaceList?它在WSDL中。为了简洁起见,我省略了它(以及许多其他内容),但如果有关系,我可以发布它。请发布整个wsdl(包括引用的模式)和整个返回soap。如果它是机密的,你也可以给我发邮件。问题是完整的WSDL只是超过了Stackoverflow上允许的消息大小。但是,我已经将其上载到SkyDrive:您可以上载.wsdl和引用的.xsd文件吗?wsdl是不够的。引用的只是一个URI,但没有URL。
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cmtypes="http://www.brightcomputing.com/cmtypes.xsd" xmlns:cmdevice="http://www.brightcomputing.com/cmdevice.wsdl">
    <s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope"></s:Header>
    <SOAP-ENV:Body>
        <cmdevice:getNodesResponse SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
            <nodes xsi:type="cmtypes:NodeList" xmlns="">
                <data xsi:type="cmtypes:MasterNode">
                    <uniqueKey xsi:type="xsd:unsignedLong">38654705666</uniqueKey>
                    <revision xsi:type="xsd:string"></revision>
                    <modified xsi:type="xsd:boolean">false</modified>
                    <toBeRemoved xsi:type="xsd:boolean">false</toBeRemoved>
[...]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="http://www.brightcomputing.com/cmtypes.xsd")]
public partial class NodeList : object, System.ComponentModel.INotifyPropertyChanged {

    private Node[] dataField;

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public Node[] data {
        get {
            return this.dataField;
        }
        set {
            this.dataField = value;
            this.RaisePropertyChanged("data");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}
<cmdevice:getNodesResponse SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <nodes xsi:type="cmtypes:NodeList" xmlns="">
        <data xsi:type="cmtypes:MasterNode">
            <uniqueKey xsi:type="xsd:unsignedLong">38654705666</uniqueKey>

            [...]
        </data>
        <data xsi:type="cmtypes:PhysicalNode">
            <uniqueKey xsi:type="xsd:unsignedLong">38654705669</uniqueKey>
            [...]
        </data>
    [...]