Object data type as parameter + Webservice + Tomcat
Arvind Chavar
Ranch Hand
Joined: May 16, 2001
Posts: 53
posted
0
I have deployed a webservice on tomcat, which has a method accepting Object as parameter.The web service code is package onjava; public class MyCalcService { public int add(Object num) { TwoNumbers inNum = (TwoNumbers)num; return inNum.getNum1() + inNum.getNum2(); } public int substract(Object num) { TwoNumbers inNum = (TwoNumbers)num; return inNum.getNum1() - inNum.getNum2(); } public String reverseId(Object num){ TwoNumbers inNum = (TwoNumbers)num; return (new StringBuffer(inNum.getId())).reverse().toString(); } }
When I execute the client I am getting following error Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Client; msg=No Ser ializer found to serialize a 'java.lang.Object' using encoding style 'http://sch emas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalArgumentExce ption: No Serializer found to serialize a 'java.lang.Object' using encoding styl e 'http://schemas.xmlsoap.org/soap/encoding/'.] at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnec tion.java:324) at org.apache.soap.rpc.Call.invoke(Call.java:205) at onjava.MyCalcClient.main(MyCalcClient.java:34) I understand the error, but isn't there a predefined mapping for data type of Object(which meets Java Bean specification).I understand that if above is the case I dont have to specify any serializer or deserializer for the object type.
Can anyone please tell me, what else I need to do to make it work?