You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by ae...@rbc.com on 2005/07/14 12:01:19 UTC

.NET cannot handle null date or decimal values sent by Axis 1.2.1

I am trying to convert my Axis 1.1 rpc/encoded web service to Axis 1.2.1 wrapped/literal web service but I have come across what I think is a showstopper...

If I populate all the decimal and date fields then everything is fine. If I leave either a decimal or date field blank then I get an exception: InvalidOperationException: There is an error in XML document.  This doesn't happen when I invoke my Axis 1.1 rpc/encoded web service from the same version of .NET.

I need to use my own classes so de/serialization uses the _Helper classes provided by Axis when using the --helperGen option on the wsdl2Java command. 

I have attached the wsdl and the all the classes.

 <<test.wsdl>>  <<DateAndDecimal_Helper.java>>  <<deploy.wsdd>>  <<TestService.java>>  <<TestServiceSoapBindingImpl.java>>  <<DateAndDecimal.java>> 

I have also included the XML for the response for both scenarios...

When decimal element is null

XML 

<?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><getDateAndDecimalResponse xmlns="http://test.axis"><getDateAndDecimalReturn><dateValue>2005-07-14T09:47:04.376Z</dateValue><decimalValue xsi:nil="true"/></getDateAndDecimalReturn></getDateAndDecimalResponse></soapenv:Body></soapenv:Envelope> 

.NET error message

[FormatException: Input string was not in a correct format.]    System.Number.ParseDecimal(String s, NumberStyles style, NumberFormatInfo info) +0    System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider) +30    System.Xml.XmlConvert.ToDecimal(String s) +100    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_DateAndDecimal(Boolean isNullable, Boolean checkType) +438    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read13_getDateAndDecimalResponse() +307  [InvalidOperationException: There is an error in XML document (1, 384).]    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +413    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events) +25    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) +24    System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1057    System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +218    Wrapped.AxisTests.TestServiceService.getDateAndDecimal(Int32 in0) in c:\webroot\wrapped\web references\axistests\reference.cs:61    Wrapped.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\webroot\wrapped\webform1.aspx.cs:97    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33    System.Web.UI.Page.ProcessRequestMain() +1292	
When date element is null
XML 
<?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><getDateAndDecimalResponse xmlns="http://test.axis"><getDateAndDecimalReturn><dateValue xsi:nil="true"/><decimalValue>4.000</decimalValue></getDateAndDecimalReturn></getDateAndDecimalResponse></soapenv:Body></soapenv:Envelope>
.NET error message
[FormatException: String was not recognized as a valid DateTime.] System.DateTimeParse.ParseExactMultiple(String s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, DateTime& result) +286 System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style) +39 System.Xml.XmlConvert.ToDateTime(String s, String[] formats) +103 System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value, String[] formats) +9 System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value) +30 System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value) +5 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_DateAndDecimal(Boolean isNullable, Boolean checkType) +358 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read13_getDateAndDecimalResponse() +307 [InvalidOperationException: There is an error in XML document (1, 333).] System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +413 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events) +25 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) +24 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1057 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +218 Wrapped.AxisTests.TestServiceService.getDateAndDecimal(Int32 in0) in c:\webroot\wrapped\web references\axistests\reference.cs:61 Wrapped.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\webroot\wrapped\webform1.aspx.cs:97 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292 

Environment
Axis 1.2.1 wrapped/literal service deployed to websphere server
WebSphere Platform 5.1 [BASE 5.1.1 a0426.01] [JDK 1.4.2 cn1420-20040626] [PME 5.1.1 o0429.02]  running with process name localhost\localhost\server1 and process id 3052
Host Operating System is Windows 2000, version 5.0
Java version = J2RE 1.4.2 IBM Windows 32 build cn1420-20040626 (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM

Microsoft Development Environment 2003
Microsoft .NET Framework 1.1
Microsoft Visual C# .NET 69586-335-0000007-18998 


__________________________________________________________________________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.  

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

Re: .NET cannot handle null date or decimal values sent by Axis 1.2.1

Posted by Anne Thomas Manes <at...@gmail.com>.
This is a known problem in .NET. It doesn't support nulls in a number
of different types. Rather than sending a null (nillable="true") you
have to simply not send the element (nillable="false" minOccurs="0").

Anne

On 7/14/05, aedemar.cooke@rbc.com <ae...@rbc.com> wrote:
>  
> 
> I am trying to convert my Axis 1.1 rpc/encoded web service to Axis 1.2.1
> wrapped/literal web service but I have come across what I think is a
> showstopper... 
> 
> If I populate all the decimal and date fields then everything is fine. If I
> leave either a decimal or date field blank then I get an exception:
> InvalidOperationException: There is an error in XML document.  This doesn't
> happen when I invoke my Axis 1.1 rpc/encoded web service from the same
> version of .NET. 
> 
> I need to use my own classes so de/serialization uses the _Helper classes
> provided by Axis when using the --helperGen option on the wsdl2Java command.
> 
> I have attached the wsdl and the all the classes. 
> 
>  <<test.wsdl>> <<DateAndDecimal_Helper.java>> <<deploy.wsdd>>
> <<TestService.java>> <<TestServiceSoapBindingImpl.java>>
> <<DateAndDecimal.java>> 
> 
> I have also included the XML for the response for both scenarios... 
> 
> When decimal element is null 
> 
> XML 
> 
> <?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><getDateAndDecimalResponse
> xmlns="http://test.axis"><getDateAndDecimalReturn><dateValue>2005-07-14T09:47:04.376Z</dateValue><decimalValue
> xsi:nil="true"/></getDateAndDecimalReturn></getDateAndDecimalResponse></soapenv:Body></soapenv:Envelope>
> 
> .NET error message 
> 
> [FormatException: Input string was not in a correct format.]   
> System.Number.ParseDecimal(String s, NumberStyles style, NumberFormatInfo
> info) +0    System.Decimal.Parse(String s, NumberStyles style,
> IFormatProvider provider) +30    System.Xml.XmlConvert.ToDecimal(String s)
> +100   
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_DateAndDecimal(Boolean
> isNullable, Boolean checkType) +438   
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read13_getDateAndDecimalResponse()
> +307  [InvalidOperationException: There is an error in XML document (1,
> 384).]   
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, String encodingStyle, XmlDeserializationEvents events) +413   
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, XmlDeserializationEvents events) +25   
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader) +24   
> System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
> message, WebResponse response, Stream responseStream, Boolean asyncCall)
> +1057   
> System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters) +218   
> Wrapped.AxisTests.TestServiceService.getDateAndDecimal(Int32
> in0) in c:\webroot\wrapped\web
> references\axistests\reference.cs:61   
> Wrapped.WebForm1.Button1_Click(Object sender, EventArgs e) in
> c:\webroot\wrapped\webform1.aspx.cs:97   
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 
>  
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57   
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18   
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
> postData) +33    System.Web.UI.Page.ProcessRequestMain()
> +1292       
>  When date element is null 
> XML 
> <?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><getDateAndDecimalResponse
> xmlns="http://test.axis"><getDateAndDecimalReturn><dateValue
> xsi:nil="true"/><decimalValue>4.000</decimalValue></getDateAndDecimalReturn></getDateAndDecimalResponse></soapenv:Body></soapenv:Envelope>
> 
> .NET error message 
> [FormatException: String was not recognized as a valid DateTime.]
> System.DateTimeParse.ParseExactMultiple(String s, String[]
> formats, DateTimeFormatInfo dtfi, DateTimeStyles style, DateTime& result)
> +286 System.DateTime.ParseExact(String s, String[] formats, IFormatProvider
> provider, DateTimeStyles style) +39
> System.Xml.XmlConvert.ToDateTime(String s, String[]
> formats) +103
> System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String
> value, String[] formats) +9
> System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String
> value) +30
> System.Xml.Serialization.XmlSerializationReader.ToDateTime(String
> value) +5
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_DateAndDecimal(Boolean
> isNullable, Boolean checkType) +358
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read13_getDateAndDecimalResponse()
> +307 [InvalidOperationException: There is an error in XML document (1,
> 333).]
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, String encodingStyle, XmlDeserializationEvents events) +413
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, XmlDeserializationEvents events) +25
> System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader) +24
> System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
> message, WebResponse response, Stream responseStream, Boolean asyncCall)
> +1057
> System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters) +218
> Wrapped.AxisTests.TestServiceService.getDateAndDecimal(Int32
> in0) in c:\webroot\wrapped\web
> references\axistests\reference.cs:61
> Wrapped.WebForm1.Button1_Click(Object sender, EventArgs e) in
> c:\webroot\wrapped\webform1.aspx.cs:97
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
> postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292
> 
> Environment
>  Axis 1.2.1 wrapped/literal service deployed to websphere server 
> WebSphere Platform 5.1 [BASE 5.1.1 a0426.01] [JDK 1.4.2 cn1420-20040626]
> [PME 5.1.1 o0429.02]  running with process name localhost\localhost\server1
> and process id 3052 
> 
> Host Operating System is Windows 2000, version 5.0 
> Java version = J2RE 1.4.2 IBM Windows 32 build cn1420-20040626 (JIT enabled:
> jitc), Java Compiler = jitc, Java VM name = Classic VM 
> 
> Microsoft Development Environment 2003 
> Microsoft .NET Framework 1.1 
> Microsoft Visual C# .NET 69586-335-0000007-18998 
> __________________________________________________________________________________________________________________________________
> 
> This e-mail may be privileged and/or confidential, and the sender does not
> waive any related rights and obligations.
> Any distribution, use or copying of this e-mail or the information it
> contains by other than an intended recipient is unauthorized.
> If you received this e-mail in error, please advise me (by return e-mail or
> otherwise) immediately. 
> 
> Ce courrier �lectronique est confidentiel et prot�g�. L'exp�diteur ne
> renonce pas aux droits et obligations qui s'y rapportent.
> Toute diffusion, utilisation ou copie de ce message ou des renseignements
> qu'il contient par une personne autre que le (les) destinataire(s)
> d�sign�(s) est interdite.
> Si vous recevez ce courrier �lectronique par erreur, veuillez m'en aviser
> imm�diatement, par retour de courrier �lectronique ou par un autre moyen.
>  
>