Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
C# 为什么为这个WSDL生成的.NET代理会删除一些数据?_C#_Asp.net_Wcf_Soap_Wsdl - Fatal编程技术网

C# 为什么为这个WSDL生成的.NET代理会删除一些数据?

C# 为什么为这个WSDL生成的.NET代理会删除一些数据?,c#,asp.net,wcf,soap,wsdl,C#,Asp.net,Wcf,Soap,Wsdl,我已使用以下WSDL向.NET项目添加了WCF服务引用: 它生成代理类等,我可以调用这些方法。但是,调用“getCAPAlert”或“getCAPAlert”时,返回值似乎缺少数据。例如,“getCAPAlert”返回一个“alert”实例,但其“info”属性始终为空。使用Fiddler,我可以检查XML并查看是否从服务器返回了一个元素(见下文)。一个可能相关的注释:“info”在wsdl中定义为0..unbounded on“alert”,并在代理中生成一个数组。此外,该行为与使用WSE3

我已使用以下WSDL向.NET项目添加了WCF服务引用:

它生成代理类等,我可以调用这些方法。但是,调用“getCAPAlert”或“getCAPAlert”时,返回值似乎缺少数据。例如,“getCAPAlert”返回一个“alert”实例,但其“info”属性始终为空。使用Fiddler,我可以检查XML并查看是否从服务器返回了一个元素(见下文)。一个可能相关的注释:“info”在wsdl中定义为0..unbounded on“alert”,并在代理中生成一个数组。此外,该行为与使用WSE3的.NET2.0样式的web引用相同

作为一种解决方法,我编写了一些类,这些类执行它们自己的XML序列化(即实现IXmlSerializable),这些类按照预期进行反序列化(ie info!=null)。然而,手工编写这些代码容易出错,并且还有其他一些缺点

为什么生成的代理类不能正确反序列化?纠正这个问题的最佳方法是什么

SOAP响应:

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
    <ns1:serverTime soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://dmi-services.org/CAP/1.0"></ns1:serverTime>
</soapenv:Header>
<soapenv:Body>
    <ns2:getCAPAlertResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://dmi-services.org">
        <getCAPAlertReturn>
            <identifier>EINC171254539121009-6228</identifier>
            <sender>dmis@cmiservices.org</sender>
            <sent>2009-12-10T17:12:05</sent>
            <status>Test</status>
            <msgType>Alert</msgType>
            <source xsi:nil="true"/>
            <scope>Private</scope>
            <restriction xsi:nil="true"/>
            <addresses xsi:nil="true"/>
            <code></code>
            <note xsi:nil="true"/>
            <references xsi:nil="true"/>
            <incidents xsi:nil="true"/>
            <info>
                <language xsi:nil="true"/>
                <category>Other</category>
                <event>TEST TEST TEST Automobile Accident</event>
                <urgency>Past</urgency>
                <severity>Minor</severity>
                <certainty>Unlikely</certainty>
                <audience xsi:nil="true"/>
                <effective xsi:nil="true"/>
                <onset xsi:nil="true"/>
                <expires xsi:nil="true"/>
                <senderName>Customer Name</senderName>
                <headline>TEST TEST FROM ETEAM INCIDENT</headline>
                <description>desctiption</description>
                <instruction xsi:nil="true"/>
                <web xsi:nil="true"/>
                <contact xsi:nil="true"/>
            </info>
        </getCAPAlertReturn>
    </ns2:getCAPAlertResponse>
</soapenv:Body>

生成的“警报”代理类:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:oasis:names:tc:emergency:cap:1.1")]
public partial class Alert : object, System.ComponentModel.INotifyPropertyChanged {

    private string identifierField;

    private string senderField;

    private string sentField;

    private status statusField;

    private msgType msgTypeField;

    private string sourceField;

    private System.Nullable<scope> scopeField;

    private string restrictionField;

    private string addressesField;

    private string[] codeField;

    private string noteField;

    private string referencesField;

    private string incidentsField;

    private info[] infoField;

    /// <remarks/>
    public string identifier {
        get {
            return this.identifierField;
        }
        set {
            this.identifierField = value;
            this.RaisePropertyChanged("identifier");
        }
    }

    /// <remarks/>
    public string sender {
        get {
            return this.senderField;
        }
        set {
            this.senderField = value;
            this.RaisePropertyChanged("sender");
        }
    }

    /// <remarks/>
    public string sent {
        get {
            return this.sentField;
        }
        set {
            this.sentField = value;
            this.RaisePropertyChanged("sent");
        }
    }

    /// <remarks/>
    public status status {
        get {
            return this.statusField;
        }
        set {
            this.statusField = value;
            this.RaisePropertyChanged("status");
        }
    }

    /// <remarks/>
    public msgType msgType {
        get {
            return this.msgTypeField;
        }
        set {
            this.msgTypeField = value;
            this.RaisePropertyChanged("msgType");
        }
    }

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

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

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

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

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

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

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

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

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

    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));
        }
    }
}
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Xml”,“2.0.50727.4927”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.SoapTypeAttribute(Namespace=“urn:oasis:names:tc:emergency:cap:1.1”)]
公共部分类警报:对象,System.ComponentModel.INotifyPropertyChanged{
私有字符串标识符字段;
私有字符串发送器字段;
私有字符串字段;
私有状态字段;
私有msgType msgTypeField;
私有字符串源字段;
私有系统。可为空的scopeField;
私有字符串限制字段;
私有字符串地址字段;
私有字符串[]码域;
私有字符串字段;
私有字符串引用字段;
私人字符串意外事件字段;
私有信息[]信息域;
/// 
公共字符串标识符{
得到{
返回此.identifierField;
}
设置{
this.identifierField=值;
此.RaisePropertyChanged(“标识符”);
}
}
/// 
公共字符串发送器{
得到{
返回此.senderField;
}
设置{
this.senderField=值;
本.RaiseProperty变更(“发送方”);
}
}
/// 
已发送公共字符串{
得到{
返回此.sentField;
}
设置{
this.sentField=值;
本.RaiseProperty变更(“发送”);
}
}
/// 
公众地位{
得到{
返回此.status字段;
}
设置{
this.statusField=值;
本.RaiseProperty变更(“状态”);
}
}
/// 
公共msgType msgType{
得到{
返回此.msgTypeField;
}
设置{
this.msgTypeField=值;
此.RaisePropertyChanged(“msgType”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串源{
得到{
返回此.sourceField;
}
设置{
this.sourceField=值;
本.RaisePropertyChanged(“来源”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共系统。可为空的作用域{
得到{
返回此.scopeField;
}
设置{
this.scopeField=值;
本.提高产权变更(“范围”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串限制{
得到{
返回此.restrictionField;
}
设置{
this.restrictionField=值;
本.提高产权变更(“限制”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串地址{
得到{
返回此.Addresses字段;
}
设置{
this.addressesField=值;
本.RaiseProperty变更(“地址”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串[]代码{
得到{
返回此.codeField;
}
设置{
this.codeField=值;
本.RaisePropertyChanged(“代码”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串注释{
得到{
返回此.noteField;
}
设置{
this.noteField=值;
本.增加财产变更(“注释”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串引用{
得到{
返回此.referencesField;
}
设置{
this.referencesField=值;
本.RaiseProperty变更(“参考”);
}
}
/// 
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共字符串事件{
得到{
返回此.incidentsField;
}
设置{
this.incidentsField=值;
本.RaiseProperty变更(“事件”);
}
}
///         
[System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
公共信息[]信息{
得到{
返回this.infoField;
}
设置{
this.infoField=值;
本.RaisePropertyChanged(“信息”);
}
}
公共事件System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
受保护的void RaisePropertyChanged(字符串propertyName){
System.ComponentModel.PropertyChangedEventHandler propertyChanged=this.propertyChanged;
如果((属性)已更改