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 ax...@ws.apache.org on 2004/07/30 10:24:40 UTC

[jira] Updated: (AXIS-1362) Axis 1.2 bata can not process List

The following issue has been updated:

    Updater: Bruce Chen (mailto:usabcd@hotmail.com)
       Date: Fri, 30 Jul 2004 1:24 AM
    Comment:
Dear Axis developer, Here is some test code on many feature of Axis, 
just modify build.properties to change web server, you will see the error on java.util.List Serializing.

and command as below:

ant dist  (compile)
ant deploy (deploy to tomcat)
ant test  (observe result)
    Changes:
             Attachment changed to axis.zip
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/AXIS-1362?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/AXIS-1362

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: AXIS-1362
    Summary: Axis 1.2 bata can not process List
       Type: Bug

     Status: Unassigned
   Priority: Major

    Project: Axis
 Components: 
             Serialization/Deserialization
   Versions:
             1.2 Beta

   Assignee: 
   Reporter: Bruce Chen

    Created: Mon, 17 May 2004 4:22 AM
    Updated: Fri, 30 Jul 2004 1:24 AM
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

Description:
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;
    }

}




---------------------------------------------------------------------
JIRA INFORMATION:
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