axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sven Schroebler" <sven.schroeb...@uni-muenster.de>
Subject AW: AW: [Axis2] Converting an OMElement into an Array of Objects
Date Tue, 16 Jan 2007 19:01:29 GMT
Hi Ahmet!

After a good bit of work, I finally managed to solve the problem for me.
The reason that I needed to deal with an OMElement was that I tried to
transfer (Array-)Lists via Axis. At first, Axis Java2WSDL-Tool generated
<xsd:anyType>-Elements into the schema to represent the lists to be
transferred in the WSDL-File. anyType doesn't specify "any" specific data
type, therefore the server/client-code generated by WSDL2Java only contains
the most general type OMElement (using ADB-data binding) or XMLObject (using
XMLBeans).

I solved the problem by only transferring Arrays of Objects.
So in case you are also trying to transfer lists at any stage, change them
to arrays of the desired type. The Java2WSDL-Tool will than generate
XML-Schema with the specified data types. 

If you need to resize arrays, you can easily find methods that provide this
functionality on the internet.

By the way: I started with ADB databinding and switched to XMLBeans, as it
provides full XML-Schema support - according to the release notes. 
(Remember that with XMLBeans you fill an XMLBeans-Object-Array like this: 1.
O[] x=new O[length] 2. Each object in x: O y = O.factory.newInstance(). 3.
O[i]=y )

I hope this helps!
Best Regards,
Sven


-----Ursprüngliche Nachricht-----
Von: Ahmet Koc [mailto:akoc@informatik.uni-bremen.de] 
Gesendet: Dienstag, 16. Januar 2007 17:28
An: axis-user@ws.apache.org
Betreff: Re: AW: [Axis2] Converting an OMElement into an Array of Objects

Hello Sven,

i have the same problem. Have you an idea how to convert an omelement to 
an array?

cheers
ahmet

> Hi all,
>
> on the *client* side, the following exception is thrown:
>
> Exception in thread "main" _java.lang.NullPointerException_
>
> at herbieclient.test.holeBenutzer(_test.java:73_)
>
> at herbieclient.test.main(_test.java:28_)
>
> Line 73: System.out.println(buddies1.getName());
>
> On the server side no exception is thrown.
>
> Now, in order to understand the problem I have added the following 
> code in the server class right after the server code described in my 
> first mail:
>
> //Setting the OMElement in the UserDesktopBean
>
> bean.setBuddies(omElementBUD);
>
> *new:*
>
> HerbieObjectDesktopBean[] budtest = (HerbieObjectDesktopBean[]) 
> BeanUtil.deserialize(omElementBUD, new 
> Object[]{HerbieObjectDesktopBean.class},new 
> AxisService().getObjectSupplier());
>
> System.out.println(budtest.length);
>
> Now, the following exception is thrown on the *server* side:
>
> java.lang.ClassCastException: 
> org.apache.axiom.om.impl.llom.OMDocumentImpl at 
> org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:423)
>
> at herbie.core.desktop.handler.UserHandler.get(UserHandler.java:255)
>
> at 
>
herbie.core.desktop.handler.HerbieWSSkeleton.UserGet(HerbieWSSkeleton.java:8
6)
>
> at 
>
herbie.core.desktop.handler.HerbieWSMessageReceiverInOut.invokeBusinessLogic
(HerbieWSMessageReceiverInOut.java:74)
>
> at 
>
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(Abstract
InOutSyncMessageReceiver.java:39)
>
> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:493)
>
> at 
>
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HT
TPTransportUtils.java:319)
>
> at 
> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:247)
>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> at 
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:252)
>
> at 
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
>
> at herbie.core.gui.filter.CharsetFilter.doFilter(CharsetFilter.java:27)
>
> at 
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:202)
>
> at 
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
>
> at 
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:213)
>
> at 
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:178)
>
> at 
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)
>
> at 
>
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)
>
> at 
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:107)
>
> at 
>
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>
> at 
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>
> at 
>
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:744)
>
> at 
>
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav
a:527)
>
> at 
>
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo
rkerThread.java:80)
>
> at 
>
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:684)
>
> at java.lang.Thread.run(Thread.java:595)
>
> Regards,
>
> Sven
>
> ------------------------------------------------------------------------
>
> *Von:* Yadav, Yogendra (IT) [mailto:Yogendra.Yadav@morganstanley.com]
> *Gesendet:* Dienstag, 9. Januar 2007 18:16
> *An:* axis-user@ws.apache.org
> *Betreff:* RE: [Axis2] Converting an OMElement into an Array of Objects
>
> what is the exception ?
>
> ------------------------------------------------------------------------
>
> *From:* Sven Schroebler [mailto:sven.schroebler@uni-muenster.de]
> *Sent:* Tuesday, January 09, 2007 12:04 PM
> *To:* axis-user@ws.apache.org
> *Subject:* [Axis2] Converting an OMElement into an Array of Objects
>
> Hi All,
>
> I am quite new to Axis2 and I am trying to develop a webservice for an 
> existing webapplication.
>
> So far I managed to set up a basic webservice that transfers JavaBeans 
> (e.g. “UserDesktopBean”) and it possible to access all of the simple 
> data types from the client application. Unfortunately, even after 
> reading multiple AXIOM tutorials, I don’t know how to correctly work 
> with the JavaBeans nested inside the “UserDesktopBeans” that need to 
> be transferred as via AXIOM OMElement-wrapping.
>
> At this time I use the following code to return an array of Objects as 
> an OMElement:
>
> SERVER:
>
> ###########
>
> //Converting an ArrayList to Array
>
> Object[] budlist = buddies.toArray();
>
> QName budQName = new 
> QName("http://desktop.core.herbie.buddies","buddies");
>
> OMElement omElementBUD = BeanUtil.getOMElement(budQName, budlist, 
> null, false, null);
>
> //Setting the OMElement in the UserDesktopBean
>
> bean.setBuddies(omElementBUD);
>
> CLIENT:
>
> ############
>
> //here I am trying to transform the array back
>
> OMElement _buddies = benutzer.getBuddies();
>
> ObjectSupplier os = new AxisService().getObjectSupplier();
>
> Object[] budlist=new Object[]{HerbieWSStub.HerbieObjectDesktopBean.class};
>
> Object[] buddies = BeanUtil.deserialize(_buddies,budlist,os);
>
> //here I am trying to access the first array element
>
> HerbieWSStub.HerbieObjectDesktopBean buddies1 = 
> (HerbieWSStub.HerbieObjectDesktopBean) buddies[0];
>
> System.out.println(buddies1.getName());
>
> Trying to access the array leads to an Exception at this time.
>
> I would really appreciate, if you could help me with this problem.
>
> For a better understanding of the underlying webservice, I’ve attached 
> the UserDesktopBean, the WSDL-File and the services.xml
>
> Best Regards,
> Sven
>
> ------------------------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender 
> does not intend to waive confidentiality or privilege. Use of this 
> email is prohibited when received in error.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message