Hi,

First I wanted to say hi to everybody. I am pretty excited about such technology like 
JiBX. I need it to map java objects generated from CORBA IDL to XMLs used as an input 
for a web based application.

I am very sorry if I have omitted this problem being discussed somewhere in the 
documentation, if so please direct me to the proper source of black magic lore;-)

I am trying to do a simple round trip marshalling/demarshalling. The XML generated 
from the object looks ok, but when I try to unmarshal it back to another object, then 
all I get is the following exception:
"Expected start tag, found end tag "msgNumber" (line 3, col 30)"
I tried to change the order of tags and the exception always refers to the first tag. 

Read on the gory details:

The mapping:
<?xml version="1.0" encoding="UTF-8"?>
<binding>
        <mapping name="outputMessage" class="PRMSG.PricingMessage">
                <value name="msgNumber" field="msgNumber"/>
                <value name="msgType" field="msgType"/>
                <value  name="msgAirlineCode" 
                                field="msgAirlineCode"
                                serializer = "JibXMappingTest.serializeCharTable4"
                                deserializer = 
"JibXMappingTest.deserializeCharTable4"/>
                <value name="msgText" field="msgText"/>
        </mapping>
</binding>

The XML generated during marshaling:
<?xml version="1.0"?>
<outputMessage>
    <msgNumber>12</msgNumber>
    <msgType>66</msgType>
    <msgAirlineCode>KRK </msgAirlineCode>
    <msgText>msgText content</msgText>
</outputMessage> 

The class to be unmarshaled to:
package PRMSG;
        public final class PricingMessage implements org.omg.CORBA.portable.IDLEntity
        {
          public char msgType = (char)0;
          public short msgNumber = (short)0;
          public char msgAirlineCode[] = null;
          public String msgText = null;
        } // class PricingMessage

And here's the test class where I do the marshaling and unmarshaling:

import PRMSG.*;
import org.jibx.runtime.*;
import java.io.*;
public class JibXMappingTest 
{
        public static void main(String[] args) {
                PricingMessage message;
                char[] tmpArr = {'K', 'R', 'K', ' '};
                message = new PricingMessage('B', (short)12, tmpArr, "msgText 
content");
                try{
                        //to XML
                        IBindingFactory bfact = 
BindingDirectory.getFactory(PRMSG.PricingMessage.class);
                        IMarshallingContext mctx = bfact.createMarshallingContext();
                        mctx.setIndent(4);
                        mctx.marshalDocument(message, null, null,
                                new FileOutputStream("MGfilename.xml"));
                        //from XML
                        IUnmarshallingContext uctx = 
bfact.createUnmarshallingContext();
                        Object obj = uctx.unmarshalDocument
                                (new FileInputStream("MGfilename.xml"), null);
                        PricingMessage outMsg;
                        outMsg = (PricingMessage)obj;
                        System.out.println("msgAirlineCode ->" + new 
String(outMsg.msgAirlineCode) + "<-");
                        System.out.println("msgText ->" + outMsg.msgText + "<-");
                        System.out.println("msgType ->" + outMsg.msgType + "<-");
                        System.out.println("msgNumber ->" + outMsg.msgNumber + "<-");
                } 
                catch (Exception ex)
                {
                        System.out.println(ex.getMessage());
                }
                
                }

        public static String serializeCharTable4(char[] charTbl) {
                return new String(charTbl);
        }               


        public static char[] deserializeCharTable4(String text) {
                return text.toCharArray();
        }
}


Thanks,

Michal

-- 
Michal Grzemowski
Programmer/Analyst

Sabre Polska Sp z o.o.
ul. Cystersow 13A
31-553 Krakow, Poland

tel: +48 12 295 9056
fax: +48 12 295 9001
----------------------


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id?66&op=click
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to