I have a webservice in which I am trying to return a List back to my client and am getting "qname not found message". I have temporarily resolved this by changing my List to Object[] and casting the object I want to return to an array. However I would like to use the List if possible here is my sample code:
public List nonPOAProcess() throws org.apache.axis2.AxisFault {
List suspendList = new ArrayList();
try {
popper = defineNonPOAPopStructure();
popper.setWaitSeconds(-1);
if (popper.pop()) {
String orderNumber = popper.getPopulatedDataQueueEntry().getField("ORDERNUM").toString();
suspendList = POSHIManager.getManager().getSuspendInfo(orderNumber);
}
} catch (Exception e) {
throw new org.apache.axis2.AxisFault(e.getMessage());
}
return suspendList;
}
Are you sure that you can
Are you sure that you can send an array list??? You client is supposed to receive a SOAP Message. Your problem is not in you service code.
And you don't have to use QName. If you create an Option object you can use setAction() method.
opt.setAction("urn:action From WSDL").
This is for Axis 1.2. In 1.3 there are some changes
epp Did I mention that I
epp
Did I mention that I am a newbie to using Axis2? I don't know if I can use arrayList (I just want to). I am creating the webservice by creating the service first and then using a script to run java2wsdl to create my wsdl. Since I need to query our db the get rows of data I am using a result set and populating a List which I want to return to the client. The only way I have been able to get it to work is use string array as the return value and cast it as an array. Any other help would be much appreciate, TIA.
Same problem
Hello,i am a newbie too and i had the same problem like some other guys had before me. I had a webservice returning with an ArrayList of a POJO. Then i saw, we should use an array instead of a List. My problem is how can i get the array on the client side from the RPCServiceClient?
My webservice is:
ReportBean[] listPrintableReports() {...}
and in the client i try:
Object[] response = serviceClient.invokeBlocking(opListPrRep,
opListPrRepArgs, new Class[] {ReportBean.class} );
First i tried to get the ReportBean array like this:
ReportBean result = (ReportBean) response[0];
but it retuned just with the first element of the array.
Second, i tried:
ReportBean[] result = (ReportBean[]) response[0];
or
ReportBean[] result = (ReportBean[]) response;
then i got an ClassCastException.
Could anybody help for a lamer like me? Anyhelp would be much appreciate,
help please
I want to send from axis to a client many same objects. I try to return them as an array as you say but tomcat hits an error saying there was an error trying to invoke method getLocation. Can you post your whole code. Mine is the following:
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
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client
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
options.setTo(targetEPR);
QName opGetNode =new QName(" http://service.netmode.ntua.gr
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()
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;
}
Try this
ReportBean[] result = (ReportBean[]) response; should not produce a class cast exception. Is the client side ReportBean & server side ReportBean the same (do they belong to the same package)
How will the following code behave if included in you class:
for(int i=0; i< result.lenght; i++){
ReportBean bean = (ReportBean) result[i];
}
I had same problem and found the solution
Hello !
Probably late for you but could help a lot of people with same problem.
The solution was:
1) Note that to get a Fiber array I need to pass Fiber[].class and not Fiber.class.
2) Note that the array come back into response[0] and not in response.
HTH
--
Wagner Correa Ramos - +55 (19)9210-9602
wagner@object.com.br
____http://www.object.com.br __________
Heterogeneous System Integration
and Database Replication
Try the following
You will have to change you code as follows:
public List nonPOAProcess() throws org.apache.axis2.AxisFault {
List suspendList = new ArrayList();
try {
popper = defineNonPOAPopStructure();
popper.setWaitSeconds(-1);
if (popper.pop()) {
String orderNumber = popper.getPopulatedDataQueueEntry().getField("ORDERNUM").toString();
suspendList = POSHIManager.getManager().getSuspendInfo(orderNumber);
}
} catch (Exception e) {
throw new org.apache.axis2.AxisFault(e.getMessage());
}
return (TheBean[]) suspendList.toArray(new TheBean[suspendList.size()]);
}
Please note that TheBean is the name of the class of objects that is included within the suspendList. Please replace that with the appropriate class name.
How to return an ArrayList object from web service
in statement popper = defineNonPOAPopStructure(); what is popper ?