You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Joey Whelan <jo...@gmail.com> on 2008/02/17 21:12:38 UTC
Array of Complex Type Method Arguments in Axis2 POJO
Hello - I'm struggling with being able to pass an array of complex object types in an Axis2 POJO. I've attempted multiple different workarounds (array wrapper, arraylists, wrapper of arraylists, etc), but all result in errors.
Can anyone point out the error I'm making in the code below or simply point me at a known correct example of how to pass an array of complex type in a POJO?
thank you
Below is the trivial example I'm attempting to use and the resulting exception in the Tomcat log. Axis2 version 1.3 is being used within Tomcat version 6.0.14. From what I see in the log, there appears to be an issue with deserializing the array.
the "complex" type:
public class Message
{
private String msg;
public Message(String msg)
{
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
the service client. "serviceclient" is of RPCServiceClient type and initialized earlier. the code below works when a single object is passed (String for example).
public String echo()
{
Object[] response = null;
try
{
Message[] msgs = { new Message("hello"), new Message("world") };
QName op = new QName("http://web.jArchivix", "echo");
Object[] args = new Object[] { msgs };
Class[] returnTypes = new Class[] { String.class };
System.out.println("msg0: " + msgs[0].getMsg() + " msg[1]: " + msgs[1].getMsg());
response = this.serviceClient.invokeBlocking(op, args, returnTypes);
}
catch (Exception e)
{
e.printStackTrace();
}
return response != null ? (String) response[0] : null;
}
the Service code
public String echo(Message[] msgs)
{
Message msg0 = msgs[0];
Message msg1 = msgs[1];
return (msg0.getMsg() + " " + msg1.getMsg());
}
Below is the resulting AxisFault that is thrown in Tomcat (dump of catalina.out)
[ERROR] Exception occurred while trying to invoke service method echo
org.apache.axis2.AxisFault: jArchivix.vo.Message
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:29)
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:345)
at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:655)
at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:574)
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:535)
at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:188)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InstantiationException: jArchivix.vo.Message
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:27)
... 26 more
Below is the exception on the client side:
Feb 17, 2008 12:43:15 PM JArchivixServiceClient echo()
SEVERE: jArchivix.vo.Message
org.apache.axis2.AxisFault: jArchivix.vo.Message
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:101)
at jArchivix.web.JArchivixServiceClient.echo(JArchivixServiceClient.java:51)
at WSTestSet.testWSEcho(WSTestSet.java:96)
at WSTestSet$1.runTest(WSTestSet.java:65)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at junit.textui.TestRunner.doRun(TestRunner.java:115)
at junit.textui.TestRunner.doRun(TestRunner.java:108)
at junit.textui.TestRunner.run(TestRunner.java:76)
at WSTestSet.main(WSTestSet.java:161)
RE: Array of Complex Type Method Arguments in Axis2 POJO
Posted by Ross Allard <Ro...@sas.com>.
Joey, try adding a default constructor to your pojo.
Ross Allard
Strategic Performance Management
SAS Insitute
From: Joey Whelan [mailto:joey.whelan@gmail.com]
Sent: Sunday, February 17, 2008 3:13 PM
To: axis-user@ws.apache.org
Subject: Array of Complex Type Method Arguments in Axis2 POJO
Hello - I'm struggling with being able to pass an array of complex object types in an Axis2 POJO. I've attempted multiple different workarounds (array wrapper, arraylists, wrapper of arraylists, etc), but all result in errors.
Can anyone point out the error I'm making in the code below or simply point me at a known correct example of how to pass an array of complex type in a POJO?
thank you
Below is the trivial example I'm attempting to use and the resulting exception in the Tomcat log. Axis2 version 1.3 is being used within Tomcat version 6.0.14. From what I see in the log, there appears to be an issue with deserializing the array.
the "complex" type:
public class Message
{
private String msg;
public Message(String msg)
{
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
the service client. "serviceclient" is of RPCServiceClient type and initialized earlier. the code below works when a single object is passed (String for example).
public String echo()
{
Object[] response = null;
try
{
Message[] msgs = { new Message("hello"), new Message("world") };
QName op = new QName("http://web.jArchivix", "echo");
Object[] args = new Object[] { msgs };
Class[] returnTypes = new Class[] { String.class };
System.out.println("msg0: " + msgs[0].getMsg() + " msg[1]: " + msgs[1].getMsg());
response = this.serviceClient.invokeBlocking(op, args, returnTypes);
}
catch (Exception e)
{
e.printStackTrace();
}
return response != null ? (String) response[0] : null;
}
the Service code
public String echo(Message[] msgs)
{
Message msg0 = msgs[0];
Message msg1 = msgs[1];
return (msg0.getMsg() + " " + msg1.getMsg());
}
Below is the resulting AxisFault that is thrown in Tomcat (dump of catalina.out)
[ERROR] Exception occurred while trying to invoke service method echo
org.apache.axis2.AxisFault: jArchivix.vo.Message
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:29)
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:345)
at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:655)
at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:574)
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:535)
at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:188)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:98)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InstantiationException: jArchivix.vo.Message
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSupplier.java:27)
... 26 more
Below is the exception on the client side:
Feb 17, 2008 12:43:15 PM JArchivixServiceClient echo()
SEVERE: jArchivix.vo.Message
org.apache.axis2.AxisFault: jArchivix.vo.Message
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:101)
at jArchivix.web.JArchivixServiceClient.echo(JArchivixServiceClient.java:51)
at WSTestSet.testWSEcho(WSTestSet.java:96)
at WSTestSet$1.runTest(WSTestSet.java:65)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at junit.textui.TestRunner.doRun(TestRunner.java:115)
at junit.textui.TestRunner.doRun(TestRunner.java:108)
at junit.textui.TestRunner.run(TestRunner.java:76)
at WSTestSet.main(WSTestSet.java:161)