You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Steve Loughran <st...@apache.org> on 2005/09/13 17:58:12 UTC
[Axis2] databinding with XmlBeans
as you may note from my recently filed bugrep, I cant get databinding to
work for me. It may be java1.5, it may be my WSDL, or it may be a side
effect of the bizarre dependency graph that maven2 creates for dependent
jars.
Whatever, the point is I cannot use wsdl2java to generate xmlbeans
mapping. I can mostly live with that, because I already have, elsewhere,
xmlbeans from my XSD. All I need is to go from incoming messages to
xmlbeans.
1. is there an XmlBeans receiver I can use?
2. if not, how do I map between Axiom and XmlBeans, so that I can take a
bit of an Axiom graph and hand it to an xmlbean factory?
-steve
Re: [Axis2] databinding with XmlBeans
Posted by Steve Loughran <st...@apache.org>.
Ajith Ranabahu wrote:
> Hi Steve,
> I'm surprised to hear Code generator is not working for you! I'll look into
> it and see whether it can be fixed. (Just try it with the commandline, both
> the batch file and shell script are included)
I see that you have fixed it, but since the project doesnt build on
java1.5, the fix is still not on my system.
its somewhat moot as I am doing my own receiver to dispatch things
differently.
> As for the conversion from OM <-> Object, the code generator generates as
> set of classes called databind suppoerters with methods fromOM and toOM for
> the conversion. What it basically does is getting the pull parser from the
> XMLBeans object and hand it over to the builder. On the return journey it
> takes the pull parser from the OMElement (remember we have the pull API ;))
> and hand it over to the Parse method of the factory to build the object.
I have a helper class that tries to do the mapping, but it is getting
NPEs in the xmlbean cursor stuff when converting from OMElement to Type.
/**
* Convert axis2 stuff into a an XMLBean
*
*/
public class Axis2Beans<T extends XmlObject> {
/**
* generation-time options
*/
XmlOptions options;
public Axis2Beans() {
}
public Axis2Beans(XmlOptions options) {
this.options = options;
}
public T convert(OMElement element) {
XMLStreamReader reader =
element.getXMLStreamReaderWithoutCaching();
try {
return (T)T.Factory.parse(reader);
} catch (XmlException e) {
throw new BaseException(e);
}
}
java.lang.NullPointerException
at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.finish(Cur.java:3144)
at
org.apache.xmlbeans.impl.store.Locale.loadXMLStreamReader(Locale.java:1213)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:840)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:823)
at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:231)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:668)
at
org.smartfrog.services.deployapi.binding.Axis2Beans.convert(Axis2Beans.java:59)
What am I doing wrong? Do I really have to revert to turning stuff into
XML files to get all of this to work? Because if that is what it takes I
will.
-steve
sometimes I feel the world of XML bindings is conspiring against me.
Today is such a time
/**
* Convert a message to the body of the response.
* This does not create a SOAP document
* @param document
* @return
*/
public OMElement convert(T document) {
XMLStreamReader reader = document.newXMLStreamReader(options);
OMXMLParserWrapper builder = createBuilder(reader);
//get the root element (in this case the envelope)
return builder.getDocumentElement();
}
private OMXMLParserWrapper createBuilder(XMLStreamReader reader) {
OMXMLParserWrapper builder =
OMXMLBuilderFactory.createStAXOMBuilder(getOMFactory(),
reader);
return builder;
}
private OMFactory getOMFactory() {
return OMAbstractFactory.getOMFactory();
}
}
> If you run the code generator with -ss -sd options, it'll generate the
> message receiver with the correct conversion!
I will see if I can run this somehow.
Re: [Axis2] databinding with XmlBeans
Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi Steve,
I'm surprised to hear Code generator is not working for you! I'll look into
it and see whether it can be fixed. (Just try it with the commandline, both
the batch file and shell script are included)
As for the conversion from OM <-> Object, the code generator generates as
set of classes called databind suppoerters with methods fromOM and toOM for
the conversion. What it basically does is getting the pull parser from the
XMLBeans object and hand it over to the builder. On the return journey it
takes the pull parser from the OMElement (remember we have the pull API ;))
and hand it over to the Parse method of the factory to build the object.
If you run the code generator with -ss -sd options, it'll generate the
message receiver with the correct conversion!
On 9/13/05, Steve Loughran <st...@apache.org> wrote:
>
>
> as you may note from my recently filed bugrep, I cant get databinding to
> work for me. It may be java1.5, it may be my WSDL, or it may be a side
> effect of the bizarre dependency graph that maven2 creates for dependent
> jars.
>
> Whatever, the point is I cannot use wsdl2java to generate xmlbeans
> mapping. I can mostly live with that, because I already have, elsewhere,
> xmlbeans from my XSD. All I need is to go from incoming messages to
> xmlbeans.
>
> 1. is there an XmlBeans receiver I can use?
>
> 2. if not, how do I map between Axiom and XmlBeans, so that I can take a
> bit of an Axiom graph and hand it to an xmlbean factory?
>
> -steve
>
>
--
Ajith Ranabahu