[ 
https://jira.codehaus.org/browse/JIBX-446?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maulik Kayastha reopened JIBX-446:
----------------------------------


Hi Don,

Apologies, for the late reply. As I was bit in the transmission phase.

I am using quite older version of OTA (2006) and I don't feel any issue which 
is version specific. I resolved this issue after understanding and debugging 
JIBX code. I observed three very critical issues while resolving this problem, 
which I feel worth sharing with you.

The issues are with 1) for usage="optinal" not working for this exceptional 
case, 2) ordered="false" not working 3) The concern over manually editing 
binding.xml ...

In binding.xml I have given -

Issue-1:

<structure get-method="getChoice" set-method="setChoice" usage="optional" 
ordered="false" choice="true">
  <structure test-method="ifSuccess" usage="optional">
    <structure map-as="ns1:SuccessType" get-method="getSuccess" 
set-method="setSuccess" name="Success" usage="optional"/>
    <structure map-as="ns1:WarningsType" get-method="getWarnings" 
set-method="setWarnings" usage="optional" name="Warnings"/>
  </structure>
  <structure map-as="ns1:ErrorsType" test-method="ifErrors" 
get-method="getErrors" set-method="setErrors" usage="optional" name="Errors"/>
</structure>

My response XML has empty success tag as <success /> and <Errors> <Error> Some 
Error </Error> </Errors> tag filled with errors. So in this case as <success> 
is defined optional in the binding.xml ideally it should have been ignored, but 
that is not the case and it is expecting to have value for <success> tag which 
is not possible. Hence I have removed <success /> tag and all the other tags 
which does not have values via java programming. As this happens for all such 
type of tags which does not have value and there is no point of giving 
usage="optional" for these tags. For example - <Errors />, <Success />, 
<RoomStay /> <Packages /> etc... all such tags that do not have child element 
or attribute throws above error.

Issue-2: As you can see in above binding.xml line number 3796 -
I have given ordered="false" for Packages. 

In the response XML I am getting HolidayPackageList (HolidayPackage) first and 
CustomPackageList (CustomPackage) after that. Ideally for <Packages> while 
ordered="false" this should not be the issue, but that is not the case and 
above type of error is thrown. Hence I am forced to manually swap the order of 
CustomPackage and HolidayPackage in the binding.xml and then things are working 
fine.

Issue-3:
I also have concern on manually editing binding.xml, as I feel this is not the 
safe and right way of dealing with the things. Code maintainability would be an 
issue over here. As while any change happens to XSD we need to create new 
binding and after that we need to modify binding.xml and again run the bind 
command to bind modified binding with POJO. Things are good if I maintain this 
code for life time, but that would not be the practical case and the person who 
will need to do any change in the XSD will be in a great soup in my absence.

I have to admit JIBX is definitely a good invention, but would also request you 
to look into above issues, as they are really critical from my point of view.

Cheers,
Maulik
                
> org.jibx.runtime.JiBXException: Expected 
> "{http://www.opentravel.org/OTA/2003/05}TH_PackageSearchRS"; end tag, found 
> "{http://www.opentravel.org/OTA/2003/05}Success"; start tag (line 2, col 126)
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JIBX-446
>                 URL: https://jira.codehaus.org/browse/JIBX-446
>             Project: JiBX
>          Issue Type: Bug
>          Components: CodeGen
>    Affects Versions: JiBX 1.2.3
>         Environment: Windows XP, Apache Ant 1.7, Tomcat 5.5, Java 5
>            Reporter: Maulik Kayastha
>            Assignee: Don Corley
>            Priority: Blocker
>              Labels: Jibx, exception, runtime
>         Attachments: binding.xml, response.xml
>
>
> Hi,
> While unmarshalling response xml, I am getting exception as below -
> org.jibx.runtime.JiBXException: Expected 
> "{http://www.opentravel.org/OTA/2003/05}TH_PackageSearchRS"; end tag, found 
> "{http://www.opentravel.org/OTA/2003/05}Success"; start tag (line 2, col 126)
> I have attached binding.xml and response.xml(which I am trying to unmarshall) 
> for the reference. 
> code to unmarshall response document:
> private Object unmarshallJibxMessage(Document responseDocument) throws 
> CommsException
>    {
>       DOMImplementationLS domImplementation =
>          (DOMImplementationLS) responseDocument.getImplementation();
>       LSSerializer lsSerializer = domImplementation.createLSSerializer();
>       String xml = lsSerializer.writeToString(responseDocument);
>       try
>       {
>          IBindingFactory factory =
>             BindingDirectory.getFactory("binding", 
> "org.jibx.opentravel.ota._2003._05");
>          IUnmarshallingContext unMarshallingContext = 
> factory.createUnmarshallingContext();
>          unMarshallingContext.setDocument(new StringReader(xml));
>          return unMarshallingContext.unmarshalElement();
>       }
>       catch (JiBXException e)
>       {
>          LOG.error("JIBX Unmarshalling Exception", e);
>          throw new CommsException("JIBX Unmarshalling Exception", e);
>       }
>    }
> Please let me know if any further information is required.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to