You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Oggy Doytchinov <Do...@adr.org> on 2005/02/25 21:28:39 UTC
ClassCastException when trying to return an array of beans from a web service.
Hi,
I am trying to create a web service that returns an array or java been objects. I have written a class with a method that returns the array. My java beans are only using simple types strings and integers. But whenever I tried to call them from the TestClient class the code is failing with ClassCastException. Here is the output from the screen:
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.ClassCastException: [Ljava.lang.Object;
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.ClassCastException: [Ljava.lang.Object;
faultActor:
faultNode:
faultDetail:
java.lang.ClassCastException: [Ljava.lang.Object;
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at documents.DocumentsSoapBindingStub.getDocumentTypes(DocumentsSoapBindingStub.java:234)
at documents.TestClient.main(TestClient.java:17)
Here is the code from my TestClient class that calls the service:
IDocuments service = new IDocumentsServiceLocator().getdocuments();
DocTypeView[] resp = service.getDocumentTypes(userId, password);
The client code was generated by running java2wsdl and wsdl2java against the IDocuments interface:
public interface IDocuments {
public DocTypeView[] getDocumentTypes(String user, String password) throws Exception;
}
Here is the definition of the DocTypeView bean:
public class DocTypeView implements Serializable {
private String code;
private String description;
private String parentCode;
private String parentSubsys;
private String subsys;
public DocTypeView() {
}
... getters and setters for all of the above attributes
}
I have made a test writing a method that returns a simple string and it worked, but the moment I try to use the array or even to return a single bean I am getting an error.
Do I need to write my own serializers and deserializers for the bean? What am I doing wrong?
I would greatly appreciate any help to this problem,
Oggy Doytchinov