I'm confused to Günther, please bear with me. Well lets focus on
marshalling right now. I'm starting from code, ie, jib2wsdl . I have a
binding file it generates. My classes exist before I call any jibx
tools. I've read all the docs about 10 times - but I'm a newbie so
please bear with me. jibx has a binding file which is particular to
jibx, and does marshalling without a schema. This is unlike xmlbeans /
adb / jaxb etc - what I know well.

Say I have this binding file:

<binding xmlns:tns="http://wazollc.com/alphatheory/hibernate/bo";
name="binding" package="com.wazollc.alphatheory.hibernate.bo"
force-classes="true">
  <namespace uri="http://wazollc.com/alphatheory/hibernate/bo";
default="elements" prefix="ns1"/>
  <namespace 
uri="http://wazollc.com/alphatheory/webservices/ATWSServer/ATWSServer";
prefix="ns2"/>
  <mapping abstract="true" type-name="tns:exchangePermissionBO"
class="com.wazollc.alphatheory.hibernate.bo.ExchangePermissionBO">
    <value style="attribute" name="id" get-method="getId"
set-method="setId" usage="optional"/>
    <value style="attribute" name="version" get-method="getVersion"
set-method="setVersion" usage="optional"/>    <value style="element"
name="name" get-method="getName" set-method="setName"
usage="optional"/>
    <value style="element" name="code" get-method="getCode"
set-method="setCode" usage="optional"/>
  </mapping>
</binding>

And lets say I retrieved
com.wazollc.alphatheory.hibernate.bo.ExchangePermissionBO from a
hibernate query. I now want to marshall this ExchangePermissionBO into
xml. My best guess on how to do this is:

com.wazollc.alphatheory.hibernate.bo.ExchangePermissionBO bo =
getFromHibernate();

 IBindingFactory ibf =
org.jibx.runtime.BindingDirectory.getFactory("binding",
"com.wazollc.alphatheory.hibernate.bo",
EntityMarshaller.class.getClassLoader());
 org.jibx.runtime.IMarshallable mctx = (org.jibx.runtime.IMarshallable)bo;
 org.apache.axiom.om.OMDataSource result = new
org.apache.axis2.jibx.JiBXDataSource(mctx, ibf);
 StringWriter writer = new StringWriter();
 result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
 writer.flush();
 System.out.println("Response: " + writer.toString());

Yet 'ExchangePermissionBO bo' doesn't implement IMarshallable. You say
it doesn't need to. ok, so I'm approaching this wrong. What's the
right way - or any way - to do this?

Please help,
Robert

On Nov 16, 2007 11:16 PM, Günther Wieser <[EMAIL PROTECTED]> wrote:
> hi robert,
>
> i'm confused about the things you write in your emails. i need to ask
> you if you've read the documentation carefully on the jibx homepage?
> there is NO NEED for extending a jibx class or implementing an
> interface of jibx. jibx is straight forward, but the problem might be
> that you try to marshal/unmarshal only parts of an XML that you have
> defined in your mappings.
>
> jibx takes an xml document, and the root element of this xml needs to
> be defined as the root in your jibx binding. you cannot unmarshal an
> XML that only holds a substructure of this root binding that you
> defined.
>
> e.g.
> <client>
>         <name>Blablabla</name>
>         <account>
>                 <id>1231234</id>
>         <account>
> <client>
>
> if you define a mapping for this xml stucture, client will be the root
> element in your xml and your binding. you can unmarshal this XML
> easily as long as your binding is ok. but you cannot unmarshal the
> following document:
> <account>
>         <id>345345</id>
> </account>
> as this is NOT a defined root element in your mapping!
>
> br,
> günther
>
> Am 16.11.2007 um 03:10 schrieb robert lazarski:
>
>
> > Still struggling here, any help would be highly appreciated. My areas
> > of confusion are:
> >
> > 1) I've used 'code first' with hibernate objects and Jibx2Wsdl to
> > create my schema and wsdl. I think I need to have JiBX use get/set
> > methods rather than directly access fields with working with
> > Hibernate, so I have referenced in a file that I pass to Jibx2Wsdl:
> >
> > <custom force-classes="true" strip-prefixes="m_" property-
> > access="true">
> > </custom>
> >
> >> From an axis2 standpoint, this all works fine on my first simple
> >> service.
> >
> > 2) Now I need to marshall / unmarshall xml files to and from my
> > hibernate entities, outside of axis2 - basically importing and
> > exporting entire xml based data graphs into and out of a db controled
> > by hibernate. I need to validate these operations, so I'm using jaxp
> > against the xml schema that jibx2wsdl created.
> >
> > Step 2 is where I'm stuck:
> >
> > 2a) jibx marshalling / unmarshalling doesn't appear to be xml schema
> > based, but rather jibx binding based.
> >
> > 2b) jibx marshalling / unmarshalling of an object seems to require
> > that the object extends MarshallingContext and UnmarshallingContext or
> > implement its interface. This would tightly couple my hibernate
> > objects to jibx and perhaps needs some custom coding(not just
> > automatic), but I'd do it it if solved my problem. I tried:
> >
> > public class ExchangePermissionBO  extends MarshallingContext
> > implements java.io.Serializable {
> > ...
> > }
> >
> > But I get:
> >
> > [echo] Running Jibx2Wsdl tool
> >    [java] Exception in thread "main" java.lang.IllegalStateException:
> > No way to handle type 'java.lang.Object'
> >    [java]     at
> > org
> > .jibx
> > .binding
> > .generator.BindingGenerator.expandReferences(BindingGenerator.java:
> > 191)
> >    [java]     at
> > org
> > .jibx
> > .binding
> > .generator.BindingGenerator.expandReferences(BindingGenerator.java:
> > 207)
> >    [java]     at
> > org
> > .jibx
> > .binding
> > .generator.BindingGenerator.findReferences(BindingGenerator.java:983)
> >    [java]     at
> > org
> > .jibx
> > .binding
> > .generator.BindingGenerator.generateSpecified(BindingGenerator.java:
> > 1123)
> >    [java]     at org.jibx.ws.wsdl.Jibx2Wsdl.generate(Jibx2Wsdl.java:
> > 484)
> >    [java]     at org.jibx.ws.wsdl.Jibx2Wsdl.main(Jibx2Wsdl.java:588)
> >
> > I get the feeling I'm aproaching the xml import / export requirement
> > the wrong way. Please help,
> > Robert
> >
> > On Nov 14, 2007 12:45 PM, robert lazarski <[EMAIL PROTECTED]>
> > wrote:
> >> Ahh, just noticed - my mapping is abstract! I'm still confused about
> >> if my entity needs to be cast to IMarshallable, and what I need to
> >> do.
> >> Thanks!
> >>
> >> Robert
> >>
> >>
> >> On Nov 14, 2007 12:40 PM, robert lazarski
> >> <[EMAIL PROTECTED]> wrote:
> >>> Thanks for the reply Günther Wieser,
> >>>
> >>> These additional binding classes, when you say runtime, do I need
> >>> these in the classloader when marshalling? Or are they just for the
> >>> code gen stage of jibx?
> >>>
> >>> What's strange to me is that in my jibx based axis2 code it
> >>> handles my
> >>> objects just fine. In my working axis2 code, the code gen casts to
> >>> IMarshallable. What I may need to do is this:
> >>>
> >>> IBindingFactory ibf =
> >>> org.jibx.runtime.BindingDirectory.getFactory("binding",
> >>> "com.wazollc.alphatheory.hibernate.bo",
> >>> EntityMarshaller.class.getClassLoader());
> >>> org.jibx.runtime.IMarshallable mctx =
> >>> (org.jibx.runtime.IMarshallable)bo;
> >>>
> >>> But my hibernate objects would then be tied to jibx. Is that what I
> >>> have to do? Here's my simple mapping - AFAICT I'm doing things as
> >>> you
> >>> say I need to - do you see something wrong? Thanks for the help!!!
> >>>
> >>> <binding xmlns:tns="http://wazollc.com/alphatheory/hibernate/bo";
> >>> name="binding" package="com.wazollc.alphatheory.hibernate.bo"
> >>> force-classes="true">
> >>>  <namespace uri="http://wazollc.com/alphatheory/hibernate/bo";
> >>> default="elements" prefix="ns1"/>
> >>>  <namespace 
> >>> uri="http://wazollc.com/alphatheory/webservices/ATWSServer/ATWSServer
> >>> "
> >>> prefix="ns2"/>
> >>>  <mapping abstract="true" type-name="tns:exchangePermissionBO"
> >>> class="com.wazollc.alphatheory.hibernate.bo.ExchangePermissionBO">
> >>>    <value style="attribute" name="id" get-method="getId"
> >>> set-method="setId" usage="optional"/>
> >>>    <value style="attribute" name="version" get-method="getVersion"
> >>> set-method="setVersion" usage="optional"/>    <value style="element"
> >>> name="name" get-method="getName" set-method="setName"
> >>> usage="optional"/>
> >>>    <value style="element" name="code" get-method="getCode"
> >>> set-method="setCode" usage="optional"/>
> >>>  </mapping>
> >>> </binding>
> >>>
> >>
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > jibx-users mailing list
> > jibx-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jibx-users
> >
>
>
>
> --
> Günther Wieser
> creative-it
> Guglgasse 6/1/11/1
> A-1110 Wien
> [EMAIL PROTECTED]
> http://www.creative-it.com
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to