Hello all,
I am using xmlbeans 1.0.4 and have a strange issue at hand.
We have an old webservice which was documented in DTD and to use advanced
xmlbeans features we decided to write an xsd for it and use it at another place
to send/get WS calls. Kindly note the xsd is used only at client side..ie.e
where it invokes the WS. The WS is still the old one.
Here is a snippet of teh xsd that is causing the issue -
<xs:complexType name ="itemT">
<xs:sequence maxOccurs="1">
<xs:element name="item_id" type="xs:int" minOccurs="1"
maxOccurs="1"/>
<xs:element name="file_id" type="xs:int" minOccurs="0"
maxOccurs="1"/>
.......................................
............</xs:sequence>
</xs:complexType>
Now the 'file_id' field above is not mandatory and may be blank. The way our
old WS responds in case there is nor file_id associated with type itemT is as
follows.
<item>
<item_id>1602</item_id>
<file_id/>
..........................
</item>
SO even if there is no value for file_id it still returns an empty tag.
Now this is of type xs:int I cannot do a null check - Hence in my java code
whenever I try to access it
like
item.getFileId() - It always throws an exception stacktrace as follows
org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException
at
org.apache.xmlbeans.impl.values.JavaIntHolder.set_text(JavaIntHolder.java:42)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1085)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1224)
at
org.apache.xmlbeans.impl.values.JavaIntHolder.intValue(JavaIntHolder.java:52)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.getIntValue(XmlObjectBase.java:1442)
at com.company.webservices.live.impl.ItemTImpl.getFileId(Unknown Source)
at
com.company.live.ws.service.NewWebService.fetchItem(LiveWebService.java:150)
Is there a way in xmlbeans by which I can check that whether a "int value" is
present or not (like we do for String i.e. null check) and only then try to
retrieve the fileId value?
I tried using item.isSetFileId() but that returns as true.
I also tried item.xgetFileId() - checked if that is null but again when we try
to get intValue() it throws same exception.
Can anyone kindly help?
Thanks in advance,
SSP
Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!
http://downloads.yahoo.com/in/internetexplorer/