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 Kostis Tzanettis <kt...@gmail.com> on 2007/09/11 18:26:45 UTC
axis2 and lists
Hello,
I want to make a client ask axis2 for a list of objects. Is that possible;
Using the code below, i can see some of the db information on tomcat's logs
and if i try to send only one field such as LocationName it works fine. But
if I try to send all the objects of the list or even only one object there
is an exception: exception occurred while trying to invoke service method
getLocation and on tomcat i see a message: Mapping qname not fond for the
package: java.util
at org....
Thank you.
This is the client code:
package gr.ntua.netmode.rpcclient;
import javax.xml.namespace.QName;
import java.util.List;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference ;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.log4j.Logger;
import gr.ntua.netmode.myPaper.*;
public class topologyRPCClient {
private static Logger log =Logger.getLogger(topologyRPCClient.class);
public static void main(String[] args1) throws AxisFault {
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new
EndpointReference("http://localhost:8080/axis2/services/TopologyService
");
options.setTo(targetEPR);
QName opGetNode =new QName("http://service.netmode.ntua.gr/xsd",
"getLocation");
log.debug(opGetNode);
Object[] opGetNodeArgs = new Object[] { };
Class[] returnTypes = new Class[] { List.class };
Object[] response = serviceClient.invokeBlocking (opGetNode,
opGetNodeArgs, returnTypes);
List result = (List) response[0];
Location k=(Location) result.get(1);
System.out.println(k.getCity());
}
}
}
and this is the service code:
public List getLocation(Integer id) throws Exception {
List <Location> n=null;
Location x=null;
String y=null;
Transaction tx = null;
SessionFactory sessionFactory = new
Configuration().configure().buildSessionFactory();
Session session =sessionFactory.openSession();
System.err.println(session.isConnected());
System.err.println(session.isOpen());
try {
tx = session.beginTransaction();
System.err.println(tx.isActive());
n= session.createQuery("from Location as location").list();
x=n.get(2);
y=x.getName();
log.debug(n);
tx.commit();
System.out.println(n);
System.out.println();
System.out.println(y);
System.out.println(x.getCountry());
System.out.println(x.getAltitude());
System.out.println(x.getEmail_address());
System.out.println ();
}
catch (HibernateException e) {
e.printStackTrace();
if (tx != null && tx.isActive())
tx.rollback();
}
return n;
}
--
Kostis Tzanettis