I have been having
problems parsing incoming xml for my XMLBeans object. The classes were
generated from XSD Schemas.
XMLObjec Class
Name: VinDecodeRequest
If I populate it and
issue oVinDecodeRequest.save(...) it produces the following xml. It places
<xml-fragment> where normally integrated with our SOA system the
xml-fragment tag is replaced with the the pair of tags:
<VinDecodeRequest
xmlns="http://vindecode.servicebeans.trivin.com">
</VinDecodeRequest>
The input xml below
parses:
<?xml
version="1.0"
encoding="UTF-8"?>
<xml-fragment>
<vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID>
<vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com">
<com:Field xmlns:com="http://common.servicebeans.trivin.com">
<com:Name>VIN</com:Name>
<com:Value>4F4YR12U63TM07491</com:Value>
</com:Field>
</vin:Fields>
</xml-fragment>
<xml-fragment>
<vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID>
<vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com">
<com:Field xmlns:com="http://common.servicebeans.trivin.com">
<com:Name>VIN</com:Name>
<com:Value>4F4YR12U63TM07491</com:Value>
</com:Field>
</vin:Fields>
</xml-fragment>
The input xml does
not parse:
<?xml
version="1.0" encoding="UTF-8"?>
<VinDecodeRequest xmlns="http://vindecode.servicebeans.trivin.com">
<vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID>
<vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com">
<com:Field xmlns:com="http://common.servicebeans.trivin.com">
<com:Name>VIN</com:Name>
<com:Value>4F4YR12U63TM07491</com:Value>
</com:Field>
</vin:Fields>
</VinDecodeRequest>
<VinDecodeRequest xmlns="http://vindecode.servicebeans.trivin.com">
<vin:ProductID xmlns:vin="http://vindecode.servicebeans.trivin.com">100</vin:ProductID>
<vin:Fields xmlns:vin="http://vindecode.servicebeans.trivin.com">
<com:Field xmlns:com="http://common.servicebeans.trivin.com">
<com:Name>VIN</com:Name>
<com:Value>4F4YR12U63TM07491</com:Value>
</com:Field>
</vin:Fields>
</VinDecodeRequest>
The ONLY way i seem
to be able to read in XML and create the appropriate VinDecodeRequest object is
if the XML i'm reading in actually "contains" <xml-fragment> tags.
How can i XmlObject.parse to properly parse the incoming XML
The code i use is
fairly straight forward, i set the schematype to the appropriate
class
XmlOptions
opts = new XmlOptions();
SchemaType
type =
XmlBeans.typeForClass(com.trivin.servicebeans.vindecode.VinDecodeRequest.class);
opts.setDocumentType(type);
XmlObject
obj =
XmlObject.Factory.parse(res.getInputStream(),opts);
Is there a simple
workaround or explanation? I simply need to be able to parse that second
set of XML.
thanks for any help
or advice.

