Forums Register Login

How to pass Java vector to a web service using Apache AXIS

+Pie Number of slices to send: Send
Hi All,
When I try to pass vector to a web service, I am getting "faultDetail: {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: No deserializer defined for array type {http:/www.w3.org/2001/XMLSchema}apachesoap:Vector" error with the below code snippet.

void myWebServiceCall()
{
Vector<String> checkListIDs = new Vector<String>();
try {
Service service = new Service();
call = (Call) service.createCall();

call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY,URI_ENCODING);
call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);

call.setTargetEndpointAddress(new java.net.URL(wsdlURL));

QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
call.setReturnType(QNAME_TYPE_STRING);

QName QNAME_TYPE_VECTOR = new QName(NS_XSD,"apachesoap:Vector");
call.addParameter("chkIds", QNAME_TYPE_VECTOR, ParameterMode.IN);
call.setOperationName(new QName(serviceURL,svcName));

Object params[] = {checkListIDs};
String result = (String) call.invoke(params);

} catch (Exception ex) {
ex.printStackTrace();
}
}



Could you please let me know how to define deserializer for Vector type or how to fix this problem as soon as possible?


Below is the complete trace

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: No deserializer defined for array type {http:/www.w3.org/2001/XMLSchema}ArrayList
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: No deserializer defined for array type {http:/www.w3.org/2001/XMLSchema}ArrayList
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at myclass.myWebServiceCall(mySVC.java:178)

{http://xml.apache.org/axis/}hostname:myhost
org.xml.sax.SAXException: No deserializer defined for array type {http:/www.w3.org/2001/XMLSchema}ArrayList
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at myclass.myWebServiceCall(mySVC.java:178)

+Pie Number of slices to send: Send
The short answer is DON'T

Web services can handle arrays but not specialized Java collections like Vector or ArrayList.

Think - what would a client use a Vector for anyway?

There are very convenient methods for turning your Vector into an array.

Bill
+Pie Number of slices to send: Send
William,
But, the web service signature says it accepts only Vector as an argument type.
Is it something Vector is not at all possbile to pass as an argument or not recommeded?

Rajakumar
+Pie Number of slices to send: Send
 

the web service signature says it accepts only Vector as an argument type.


Then you should change the signature to something that's part of XML Schema. Vector is Java-only, and the whole point of web services is cross platform compatibility. There's no point in giving that up just to use a data structure that can easily be replaced by something more suitable.

Is it something Vector is not at all possbile to pass as an argument or not recommeded?


You can define a pair of serializer/deserializer classes -like the error message says- but that'd be working around a bad design (which is where you should tackle the problem).
+Pie Number of slices to send: Send
 

But, the web service signature says it accepts only Vector as an argument type.



Then the web service designer made a very serious and amateurish mistake because none of the many client side frameworks in a huge variety of programming languages will be able to use the service.

Get the word to that designer and save him/her a whole lot of trouble.

Bill
+Pie Number of slices to send: Send
May I know any sample program which demonstrates serializer/deserializer classes to pass vector as argument to a web services?
I am new to the web services, so please help me.

Rajakumar
+Pie Number of slices to send: Send
I've got a similar problem.



This is given in the WSDL file.
Now, I have to call a method which is given as follows




What I did in the client side file is




Error which am recieving is:
faultString: org.xml.sax.SAXException: No deserializer defined for array type {http://schemas.xmlsoap.org/soap/encoding/}string


Need help !!!
Thanks
+Pie Number of slices to send: Send
The above error has been solved. I simply registered the ArrayOfString class, String[] with the TypeRegistryMapping class. Now, it doesn't throw the above serialize error. Code edited is:

The human mind is a dangerous plaything. This tiny ad is pretty safe:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 7229 times.
Similar Threads
Currency Web Service almost there
Help! I caught NullPointException when call axis web service
Class cast Exceptions while accessing services - AXIS 1.4
Axis Fault
SOAP processing failure, error id = 1001
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:05:28.