How to pass Java vector to a web service using Apache AXIS
Rajakumar Kasi
Greenhorn
Joined: Jan 14, 2009
Posts: 13
posted
0
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);
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: 12268
1
posted
0
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.
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
posted
0
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: 12268
1
posted
0
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
posted
0
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.
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
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How to pass Java vector to a web service using Apache AXIS