Nullable in soap

Hi,I have developed a web service by Axis which expose a method returning a class DefaultTaxa.Then, I use the .net 2.0 to generate the corresponding class DefaultTaxa. All the fields of that class are treated as nullable except the string field. When the program is executing, the result of it is all the nullable fields are set to null despite all the fields are not null in the server side. When i remove the nullable tag of those fields, the result is right. However i went the field can indicate whether null or not. what can i do. Thank you.

Here is the definition of DefaultTaxa and soap message of the method.

using System;
using System.Collections.Generic;
using System.Text;

namespace pi.taxa
{
    /// <remarks/>
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(pi.taxa._out.DefaultOutTaxa))]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://taxa.pi/")]
    public partial class DefaultTaxa
    {

        private string procCodField;

        private System.Nullable<bool> readOnlyField;

        private System.Nullable<double> taxaField ;

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

        /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNullable = true)]
        public System.Nullable<bool> readOnly
        {
            get
            {
                return this.readOnlyField;
            }
            set
            {
                this.readOnlyField = value;
            }
        }

       /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNullable = true, ElementName="taxa")]
        public System.Nullable<double> taxa
        {
            get
            {
                return this.taxaField;
            }
            set
            {
                this.taxaField = value;
            }
        }

    }

}

===============================

< 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:Body>
    <ns1:getDefaultTaxaResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://facade.num.pi/">
      <getDefaultTaxaReturn soapenc:arrayType="ns2:DefaultTaxa[4]" xsi:type="soapenc:Array" xmlns:ns2="http://taxa.pi/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <getDefaultTaxaReturn href="#id0"/>
        <getDefaultTaxaReturn href="#id1"/>
        <getDefaultTaxaReturn href="#id2"/>
        <getDefaultTaxaReturn href="#id3"/>
      </getDefaultTaxaReturn>
    </ns1:getDefaultTaxaResponse>
    <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:DefaultTaxa" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://taxa.pi/">
      <procCod xsi:type="soapenc:string">N</procCod>
      <readOnly xsi:type="soapenc:boolean" xsi:nil="true"/>
      <taxa href="#id4"/>
    </multiRef>
    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:DefaultTaxa" xmlns:ns4="http://taxa.pi/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <procCod xsi:type="soapenc:string">N</procCod>
      <readOnly xsi:type="soapenc:boolean" xsi:nil="true"/>
      <taxa href="#id7"/>
    </multiRef>
    <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:DefaultTaxa" xmlns:ns5="http://taxa.pi/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <procCod xsi:type="soapenc:string">N</procCod>
      <readOnly xsi:type="soapenc:boolean" xsi:nil="true"/>
      <taxa href="#id10"/>
    </multiRef>
    <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:DefaultTaxa" xmlns:ns6="http://taxa.pi/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <procCod xsi:type="soapenc:string">N</procCod>
      <readOnly xsi:type="soapenc:boolean" xsi:nil="true"/>
      <taxa href="#id13"/>
    </multiRef>
    <multiRef id="id10" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:double" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1000.0</multiRef>
    <multiRef id="id7" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:double" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0.0</multiRef>
    <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:double" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0.0</multiRef>
    <multiRef id="id13" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:double" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0.0</multiRef>
  </soapenv:Body>
</soapenv:Envelope>



Answer this question

Nullable in soap

  • Nickeay

    i find the problem is casued by the element multiRef of soap message. .Net seems can't handle the multiRef in nullable way. I have configured the Axis diables the multiRef and the result becomes right.
  • Nullable in soap