returning  a dynamically-sized array from a service:
 
// webmethod
public MyType[]  Method1(RequestType req) {
  java.util.ArrayList list = new java.util.ArrayList();
  list.add(new MyType());
  list.add(...);
  ...
  return (MyType[]) list.toArray(new MyType[1]) ;
}
 
accepting an array from a client is simpler:
 
// webmethod
public MyResponse  Method1(MyRequestType req[]) {
  if (req != null) {
  for (int i=0; i < req.length; i++) {
     ...
  }
  }
}
 
 

From: Suzy Fynes [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 08, 2005 4:35 AM
To: [email protected]
Subject: Dynamic Lists in Web Services (java /axis)

Hi,

 

I’m looking for away to basically incorporate ArrayList in web services….i’m writing the service in Java and I have a list as a parameter but the size of the list is known only to the client and varies from client to client. What is the best way to incorporate dynamic lists for web services?

 

Thanks

Suzy

 

Reply via email to