BTW, I just tried encapsulating the array in another class as shown
below and it works !!!!
package sample.pojo.data;
public class ArrayOfCities
{
private String[] cities;
public void setCities(String[] inCities)
{
this.cities = inCities;
}
public String[] getCities()
{
return this.cities;
}
}
Can anyone reveal this mystery please ??
________________________________
From: Bhojraj, Santosh
Sent: Thursday, October 04, 2007 12:42 PM
To: '[email protected]'
Subject: Axis2 1.2: POJO Web service: Passing array method arguments
Hi:
I am trying out some things in Axis2 using the samples\pojoguide for
starters. I added a new method with the signature below to the
WeatherService:
public Weather[] getWeatherForCities(String[] cities)
The service has been deployed successfully on JBoss 4.0.3 SP1.
Below is the client code being used to call this new method:
QName opGetWeather4Cities = new QName("http://service.pojo.sample/xsd",
"getWeatherForCities");
String[] opGetWeather4Cities_Args = {"Boston","New York" };
Class[] arrayReturnTypes = new Class[] { Weather[].class };
Object[] weather4AllCities =
serviceClient.invokeBlocking( opGetWeather4Cities,
opGetWeather4Cities_Args, arrayReturnTypes);
System.out.println("RESPONSE Entry class: " +
weather4AllCities[0].getClass() );
Object[] allEntriesRsltArray = (Object[]) weather4AllCities[0];
System.out.println("Num Entries in Result Array:" +
allEntriesRsltArray.length );
for(int i=0, n= allEntriesRsltArray.length; i < n;i++)
{
System.out.println("Weather Info for " + (i+1) + ": " +
(null != allEntriesRsltArray[i] ?
((Weather)allEntriesRsltArray[i]).getTemperature() : "NULL") );
}
When I run the client using 'ant rpc.client', I get the following
exception:
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:56
4)
at
org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:118)
at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RP
CMessageReceiver.java:113)
at
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(Abst
ractInOutSyncMessageReceiver.java:39)
at
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:144)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReques
t(HTTPTransportUtils.java:279)
at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)
at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
r.java:81)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:178)
at
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipa
lValve.java:39)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
sociationValve.java:159)
Is this issue fixed already in the latest Axis2 release ? Does something
need to be corrected in the service specification ?
Any help would be appreciated.
THANX very much !!!!!