2009-12-30 4 views
1

J'ai ajouté une référence de service WCF à un projet .NET en utilisant ce WSDL: https://interop.cmiservices.org/axis/services/CAP1_1?wsdlPourquoi le proxy .NET généré pour ce fichier WSDL supprime-t-il certaines données?

Il génère les classes proxy, etc., et je suis en mesure d'appeler les méthodes. Cependant, lorsque vous appelez 'getCAPAlerts' ou 'getCAPAlert', les valeurs de retour semblent être des données manquantes. Par exemple, 'getCAPAlert' renvoie une instance 'alert', mais sa propriété 'info' est toujours nulle. En utilisant Fiddler, je peux examiner le XML et voir qu'un élément est renvoyé du serveur (voir ci-dessous). Une note peut-être liée: 'info' est défini comme 0..unbound sur 'alert' dans le wsdl, et un tableau est généré dans le proxy. En outre, le comportement est le même avec la référence Web .net 2.0-style en utilisant WSE3. Pour contourner le problème, j'ai écrit des classes qui font leur propre sérialisation XML (c'est-à-dire implémentent IXmlSerializable), et qui se désérialisent comme prévu (ie info! = Null). Cependant, le codage à la main de ceux-ci est sujette aux erreurs et présente d'autres inconvénients. Pourquoi les classes proxy générées ne se désérialiseraient-elles pas correctement? Quel est le meilleur moyen de corriger cela?

réponse 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>[email protected]</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> 

Generated 'alerte' classe proxy:

[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)); 
     } 
    } 
} 
+0

La propriété 'info' renvoie un tableau d'objets' info'. L'objet/info 'info' est-il sérialisable? –

+0

Le service Web vous appartient-il, de sorte que vous pouvez ajuster le schéma wsdl xsd? –

+0

Désolé d'avoir abandonné ce poste. Info a également été générée par l'outil wsdl, et malheureusement, non, ce n'est pas un service que nous contrôlons. Pats à droite, cette source n'a pas correctement implémenté une spécification. En outre, la sérialisation .net a des problèmes avec les éléments 0 .. * ... – Daniel

Répondre

1

DMIS n'a pas mis en œuvre l'objet d'alerte correctement.

Leur version utilise une majuscule <Alert> tandis que l'oasis définit comme <alert>

Il y a aussi des problèmes avec les espaces de noms, vous devez vous assurer que les espaces de noms propres sont inclus pour désérialisation.

Questions connexes