Hi All,

I am trying to integrate JiBX into Axis2 using the library example
[1]. I did manage to get it to work as I wanted, i.e. invoking the web
service through a Java client. However, because of the modifications
to binding definition, I can no longer marshal data from a file.
Here's an example:


binding.xml

<binding force-classes="true" xmlns:tns="http://www.example.com/types";>
        <namespace uri="http://www.example.com/types"; default="elements"/>
        <mapping class="com.example.Book" type-name="tns:Book"
                abstract="true">
                <value name="title" field="title" />
        </mapping>
</binding>

book.xml

<?xml version="1.0" encoding="UTF-8"?>
<Book xmlns="http://www.example.com/types";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >
        <title>Alice in Wonderland</title>
</Book>


Test.java

public static void main(String[] args) throws Exception
{
        String dataFile = "book.xml";
        IBindingFactory bfact = BindingDirectory.getFactory(Book.class);
        
        // Unmarshal information from file
        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        FileInputStream in = new FileInputStream(dataFile);
        Book book = (Book) uctx.unmarshalDocument(in, null);

        // marshal object back out to file (with nice indentation, as UTF-8)
        IMarshallingContext mctx = bfact.createMarshallingContext();
        mctx.setIndent(2);

        // FileOutputStream out = new FileOutputStream(args[1]);
        mctx.marshalDocument(book, "UTF-8", null, System.out);
}


Buildfile: build.xml

run:
     [java] Exception in thread "main" org.jibx.runtime.JiBXException:
No unmarshaller for element "{http://www.example.com/types}Book"; (line
3, col 56)
     [java]     at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2535)
     [java]     at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2681)
     [java]     at com.xplana.xb.search.Test.main(Unknown Source)
     [java] Java Result: 1

REFERENCES

[1] http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/example
-- 
The mind is everything; what you think, you become. -- Buddha

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to