cancel
Showing results for 
Search instead for 
Did you mean: 

SoapUI isn't serializing nullable int

PeceKr
New Contributor

SoapUI isn't serializing nullable int

I have datacontract with datamember of type nullable int .

 

 [DataMember(Order = 5,EmitDefaultValue = false)]
        public int? Zip { get; set; }

When I leave the Zip value empty and submit the request trough SoapUI I'm getting this error :

 

 <InnerException i:nil="true"/>
                        <Message>Input string was not in a correct format.</Message>
                        <StackTrace>at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Xml.XmlConvert.ToInt32(String s)
   at System.Xml.XmlConverter.ToInt32(String value)</StackTrace>
                        <Type>System.FormatException</Type>
                     </InnerException>
                     <Message>The value '' cannot be parsed as the type 'Int32'.</Message>
                     <StackTrace>at System.Xml.XmlConverter.ToInt32(String value)
   at System.Xml.XmlDictionaryReader.ReadElementContentAsInt()
   at System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsInt()
   at ReadAddressSearchRequestFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)</StackTrace>
                     <Type>System.Xml.XmlException</Type>
                  </InnerException>

When I run this through .net client , the request is serialized correctly and I'm getting good response.

Any ideas why I have this problem in SoapUI?

 

Thanks.

5 REPLIES 5
nmrao
Community Hero

Re: SoapUI isn't serializing nullable int

How does your request look like?

Have you tried validating the same request?

In the above excerpt, it is not showing exception from soapUI meaning it does not seem to be problem in soapUI, IMO.


Regards,
Rao.
PeceKr
New Contributor

Re: SoapUI isn't serializing nullable int

Here is my request :

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://wowway.com/Care/Query">  
  <soapenv:Header/>
   <soapenv:Body>
      <com: SearchAddress>
         <!--Optional:-->
         <com:addressSearchRequest>
            <!--Optional:-->
            <com: Address1>Test</com:Address1>            
            <com: State/>
            <!--Optional:-->
            <com: Zip/>
            <!--Optional:-->
            <com: UserName>Test</com:UserName>
         </com: addressSearchRequest>
      </com: SearchAddress>
   </soapenv:Body>
</soapenv:Envelope>

I have validation , but this error is thrown instantly from SoapUI, so I can't even debug it.

 

If I validate the request in SoapUI , I'm getting error message saying  "Invalid decimal value: expected at least one digit" .

 

Thanks.

nmrao
Community Hero

Re: SoapUI isn't serializing nullable int

It is showing correct the error that is present in the request.
<com: Zip/> is not valid as per the error.

Make it like a valid one, such as
<com: Zip>23456</com: Zip>


Regards,
Rao.
PeceKr
New Contributor

Re: SoapUI isn't serializing nullable int

Hi ,

 

Thx for your reply.

 

The thing is that Zip field is optional , so the user can leave it empty. If this is empty the SoapUI can't deserialize it , because it is type of int.

 

Thank you.

nmrao
Community Hero

Re: SoapUI isn't serializing nullable int

When you say optional, is that element optional or the value? Hope it is the element, so remove it and try validating it and then proceed calling your service.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors