web service - axis problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   chung_vu
Posted On:   Wednesday, November 17, 2004 06:27 AM

hi, I do some web service using axis and have a problem with it. Please help I have a hashtable that contains many EmployeeBean objects and a MyHashTable class that is also a bean with setHashtable() and getHashtable() and I have a BeanService class that has only one method the hashtable which contains EmployeeBean objects is passed in from another servlet in the request obj. I can check the content of the hashtable BEFORE the call.invoke() of axis from the client but when I check it from the BeanService it gives me java.util.HashMap , not EmployeeBean class. Some wrong here which may be in my deploy.wsdd or from setting the Call from clientServlet?    More>>

hi,


I do some web service using axis and have a problem with it. Please help


I have a hashtable that contains many EmployeeBean objects and a MyHashTable class that is also a bean with
setHashtable() and getHashtable() and I have a BeanService class that has only one method



the hashtable which contains EmployeeBean objects is passed in from another servlet in the request obj.


I can check the content of the hashtable BEFORE the call.invoke() of axis from the client

but when I check it from
the BeanService it gives me java.util.HashMap , not EmployeeBean class.


Some wrong here which may be in my deploy.wsdd or from setting the Call from clientServlet?
Would anyone tell me why:



Here is deploy.wsdd




xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">








qname="myNS:HashTable" xmlns:myNS="urn:BeanService"
type="java:java.util.Hashtable"
serializer="org.apache.axis.encoding.ser.MapSerializerFactory"
deserializer="org.apache.axis.encoding.ser.MapDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />




languageSpecificType="java:com.saic.axis.axisService.EmployeeBean"/>



languageSpecificType="java:com.saic.axis.axisService.MyHashTable"/>







Here is my BeanService:



public Hashtable processMyHashTable (MyHashTable myHashTable) {


this.hashTable = myHashTable.getHashTable();


System.out.println(" in BeanService check hashtable....");


//it call this method but not ok, give java.util.HashMap not EmployeeBean


checkHashTable(this.hashTable);


return this.hashTable;


}


Here my clientServlet :



String method = "processMyHashTable";


Call call = null;


Service service = null;


try {


service = new Service();


call = (Call)service.createCall();


}catch(ServiceException se) {


System.out.println(" ServiceException throws...");


}



QName qn0 = new QName("urn:BeanService", "HashTable");


QName qn1 = new QName("urn:BeanService", "EmployeeBean");


QName qn2 = new QName("urn:BeanService", "MyHashTable");



call.registerTypeMapping(
Hashtable.class, qn0, new org.apache.axis.encoding.ser.MapSerializerFactory(
java.util.Hashtable.class, qn0), new org.apache.axis.encoding.ser.MapDeserializerFactory(
java.util.Hashtable.class, qn0));



call.registerTypeMapping(
EmployeeBean.class, qn1, new org.apache.axis.encoding.ser.BeanSerializerFactory(
com.saic.axis.axisService.EmployeeBean.class, qn1), new org.apache.axis.encoding.ser.BeanDeserializerFactory(
com.saic.axis.axisService.EmployeeBean.class, qn1));



call.registerTypeMapping(
MyHashTable.class, qn2, new org.apache.axis.encoding.ser.BeanSerializerFactory(
com.saic.axis.axisService.MyHashTable.class, qn2), new org.apache.axis.encoding.ser.BeanDeserializerFactory(
com.saic.axis.axisService.MyHashTable.class, qn2));



// use this to test the result
MyHashTable myHashTable = new MyHashTable();


//get the hashtable that contains EmployeeBean from request
Hashtable hashtable = (Hashtable)req.getAttribute("list");


myHashTable.setHashTable(hashtable);


System.out.println(" check hashtable before the service");


// IT IS OK to check here, it contains EmployeeBean


checkHashTable(myHashTable.getHashTable());


//Hashtable h = null;


try {
call.setTargetEndpointAddress(new java.net.URL(getEndPoint()) );


call.setOperationName(method);


call.addParameter("myHashTable", qn2, ParameterMode.IN);


call.setReturnClass(java.util.Hashtable.class);


Hashtable h = (Hashtable)call.invoke(new Object[] {myHashTable});


System.out.println(" check hashtable after the service");


//Not OK, give java.util.HashMap in hashtable not EmployeeBean. it doesnot work from the BeanService already


checkHashTable(h);


//}
}catch(AxisFault fault) {


fault.toString();

   <<Less
About | Sitemap | Contact