[ http://issues.apache.org/jira/browse/AXIS-1362?page=comments#action_60599 ] Bruce Chen commented on AXIS-1362: ----------------------------------
This problem resolved in RC2 But found again in RC3! > Axis 1.2 bata can not process List > ---------------------------------- > > Key: AXIS-1362 > URL: http://issues.apache.org/jira/browse/AXIS-1362 > Project: Axis > Type: Bug > Components: Serialization/Deserialization > Versions: 1.2 Beta > Environment: Java(TM) 2 Runtime Environment, Standard Edition (build > 1.4.2_02-b03) > Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode) > tomcat 5.0.19 > Reporter: Bruce Chen > Attachments: axis.zip, screenshot-1.jpg > > At begin, I use Axis 1.1, > I got an Deserialization error in the follwing env. > - Call returning a simple JavaBean > - Call added a client handler( it works if not add the client handler) > when i upgrade Axis to 1.2 beta > The error message disappeared and it works. > However now it reports a Serialization error message on another operation > which returning an List and works well at Axis 1.1 > //////////////////////////////////////////////////////// > package bene.manual; > import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; > import java.util.Map; > import javax.xml.namespace.QName; > import javax.xml.rpc.ParameterMode; > import org.apache.axis.Handler; > import org.apache.axis.client.Call; > import org.apache.axis.client.Service; > import org.apache.axis.encoding.XMLType; > import org.apache.axis.encoding.ser.ArrayDeserializerFactory; > import org.apache.axis.encoding.ser.ArraySerializerFactory; > import org.apache.axis.encoding.ser.BeanDeserializerFactory; > import org.apache.axis.encoding.ser.BeanSerializerFactory; > import org.apache.axis.encoding.ser.MapDeserializerFactory; > import org.apache.axis.encoding.ser.MapSerializerFactory; > public class TestClient { > String url = "http://127.0.0.1:8080/axis/services/mytest"; > String uri = "urn:MyTest"; > Call call; > QName qname; > TestClient() { > init(); > } > void testList() throws Exception { > /// Now test List .//////////// > List list = new ArrayList(); > list.add("test111"); > list.add("test222"); > call.removeAllParameters(); > qname = new QName(uri, "ArrayOf_tns1_anyType"); > call.registerTypeMapping( > List.class, > qname, > new ArraySerializerFactory(), > new ArrayDeserializerFactory()); > call.addParameter("list", qname, ParameterMode.IN); > call.setReturnType(qname); > call.setOperationName(new QName(uri, "testList")); > List list1 = (List) call.invoke(new Object[] { list }); > for (int i = 0; i < list1.size(); i++) { > System.out.println(list1.get(i)); > } > } > // operation 2 , > void testComplex() throws Exception{ > call.removeAllParameters(); > call.setOperationName(new QName(uri, "testComplex")); > qname = new QName(uri, "MapItem"); > call.registerTypeMapping( > MapItem.class, > qname, > new BeanSerializerFactory(MapItem.class, qname), > new BeanDeserializerFactory(MapItem.class, qname)); > qname = new QName(uri, "ResultInfo"); > call.registerTypeMapping( > ResultInfo.class, > qname, > new BeanSerializerFactory(ResultInfo.class, qname), > new BeanDeserializerFactory(ResultInfo.class, qname)); > call.addParameter("string", XMLType.XSD_STRING, ParameterMode.IN); > call.setReturnType(new QName(uri, "ResultInfo")); > MapItem mi = (MapItem) call.invoke(new Object[] { "myname" }); > System.out.println(mi); > //MapItem is a simple java bean > } > void printMap(Map map) { > Iterator it = map.keySet().iterator(); > while (it.hasNext()) { > Object key = it.next(); > Object value = map.get(key); > System.out.println(key + ": " + value); > } > } > void init() { > try { > call = (Call) new Service().createCall(); > call.setTargetEndpointAddress(url); > call.setMaintainSession(true); > Handler h = new ClientHandler(); > > // if i add a client handler here, operation 2 can not work > // it works after i upgrade to axis1.2 > // but operation 1 does not work which can work under axis1.1 > > call.setClientHandlers(h, h); > } catch (Exception e) { > e.printStackTrace(); > } > } > public static void main(String[] args) throws Exception { > TestClient tc = new TestClient(); > tc.testList(); > tc.testComplex(); > > } > } > ////////////////////////////////////////////////////// > package bene.manual; > import org.apache.axis.AxisFault; > import org.apache.axis.Message; > import org.apache.axis.MessageContext; > import org.apache.axis.handlers.BasicHandler; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > public class ClientHandler extends BasicHandler{ > private static Log log = LogFactory.getLog(ClientHandler.class); > > public void invoke(MessageContext mc) throws AxisFault { > Message message; > if (!mc.getPastPivot()) { > message = mc.getRequestMessage(); > } else { > message = mc.getResponseMessage(); > } > String soap = null; > if (message != null) { > soap = message.getSOAPPartAsString(); > log.debug(soap); > //System.out.println(soap); > } > } > } > //////////////////////// > package bene.manual; > public class MapItem implements java.io.Serializable { > private String key; > private String value; > public MapItem() { > } > public MapItem(String key, String value){ > this.key = key; > this.value = value; > } > public String getKey() { > return key; > } > public void setKey(String key) { > this.key = key; > } > public String getValue() { > return value; > } > public void setValue(String value) { > this.value = value; > } > > public String toString(){ > return key + "=" + value; > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira
