aspose file tools*
The moose likes Web Services and the fly likes How to pass Java vector to a web service using Apache AXIS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to pass Java vector to a web service using Apache AXIS" Watch "How to pass Java vector to a web service using Apache AXIS" New topic
Author

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

Rajakumar Kasi
Greenhorn

Joined: Jan 14, 2009
Posts: 13
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)

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
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

Java Resources at www.wbrogden.com
Rajakumar Kasi
Greenhorn

Joined: Jan 14, 2009
Posts: 13
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
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
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).
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
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
Rajakumar Kasi
Greenhorn

Joined: Jan 14, 2009
Posts: 13
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
Aj Maven
Greenhorn

Joined: Jul 04, 2011
Posts: 22

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


Thanks
-Aj
Aj Maven
Greenhorn

Joined: Jul 04, 2011
Posts: 22

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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass Java vector to a web service using Apache AXIS
 
Similar Threads
Help! I caught NullPointException when call axis web service
Axis Fault
SOAP processing failure, error id = 1001
Class cast Exceptions while accessing services - AXIS 1.4
Currency Web Service almost there