For using collections in Axis Client. This is what we did.

>From the WSDL created the Java files using the wsdl2Java etc.

In the Java generated Beans we changed the method signature to accept a
list instead of an array.

say we had the Bean Like

GENERATED CLASS

private NestedBean[]  arrayOfNestedBeans

public NestedBean[] getArrayOfNestedBeans(){
.......................
}
public void setArrayOfNestedBeans(NestedBean[] ){
.......................
}



we changed this to accept Collection.

private NestedBean[]  arrayOfNestedBeans;
private List proxyForArrayOfNestedNeans; //


public List  getArrayOfNestedBeans(){
      return proxyForArrayOfNestedNeans;
}
public void setArrayOfNestedBeans(List list ){
      .......................etc
}

and this seems to work very well WITHOUTany Run Time Errors.

Earlier we thought we may have to maintian 2 internal variables for every
get or set as the Axis while de-serializing may be directly modifying the
variable but it looks like even if we comment out the variable
'arrayOfNestedBeans'  still it has no problem !!!!! and so led us to think
that it uses getters and setters to set the values from the SOAP Message
recieved and uses reflection to set check for the parameters and converts
it appropriately.

Thanks and Regards,

===
Gary Grewal



|---------+---------------------------->
|         |           [EMAIL PROTECTED]   |
|         |                            |
|         |           06/01/2004 07:20 |
|         |           AM               |
|         |           Please respond to|
|         |           axis-user        |
|         |                            |
|---------+---------------------------->
  
>---------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                           |
  |       To:       [EMAIL PROTECTED]                                                  
                     |
  |       cc:                                                                          
                           |
  |       Subject:  RE: is it possible to use Collections with client proxies?         
                           |
  
>---------------------------------------------------------------------------------------------------------------|




Here's a great article on using collections:
http://www-106.ibm.com/developerworks/library/ws-tip-coding.html

Bottom line: use arrays.

-----Original Message-----
From: Anne Thomas Manes [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 22, 2004 9:53 AM
To: [EMAIL PROTECTED]
Subject: RE: is it possible to use Collections with client proxies?

You should switch to arrays.

Anne

-----Original Message-----
From: matthew.hawthorne [mailto:[EMAIL PROTECTED]
Sent: Friday, May 21, 2004 2:22 PM
To: [EMAIL PROTECTED]
Subject: is it possible to use Collections with client proxies?

I've recently attempted to switch the way that I create my web service
clients, from manually configuring Call objects, to
obtaining a reference to an instance of the service interface as a
stub/proxy.  However, I am unable to get this working
when a method has a Collection as a return type or parameter.

Before, I believe that the call to:
Call.setReturnType(Collection.class)
was instructing Axis to handle these types correctly.

However now, since I'm invoking service methods directly on an
interface, I get a ClassCastException on the client side, after the data
has been returned.  If I call a method that returns an array, it works
fine.

When attempting to invoke a method which includes a Collection as a
parameter, I get the following error:

Caused by: org.xml.sax.SAXException: No deserializer defined for array
type {http://localhost:8080/axis/services/Iava}ArrayOf_tns3_anyType
             at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:2

23)
             at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:13

0)
             at
org.apache.axis.encoding.DeserializationContextImpl.endElement(Deserializati

onContextImpl.java:1053)
             at com.bluecast.xml.Piccolo.reportEndTag(Piccolo.java:1059)
             at
com.bluecast.xml.PiccoloLexer.parseCloseTagNS(PiccoloLexer.java:2154)
             at
com.bluecast.xml.PiccoloLexer.parseTagNS(PiccoloLexer.java:1338)
             at
com.bluecast.xml.PiccoloLexer.parseXMLNS(PiccoloLexer.java:1272)
             at
com.bluecast.xml.PiccoloLexer.parseXML(PiccoloLexer.java:1240)
             at com.bluecast.xml.PiccoloLexer.yylex(PiccoloLexer.java:4754)
             at com.bluecast.xml.Piccolo.yylex(Piccolo.java:1253)
             at com.bluecast.xml.Piccolo.yyparse(Piccolo.java:1363)
             at com.bluecast.xml.Piccolo.parse(Piccolo.java:702)
             at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
             at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationCon

textImpl.java:218)
             at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:568)
             at org.apache.axis.Message.getSOAPEnvelope(Message.java:427)
             at org.apache.axis.client.Call.invokeEngine(Call.java:2708)
             at org.apache.axis.client.Call.invoke(Call.java:2671)
             at org.apache.axis.client.Call.invoke(Call.java:2357)
             at org.apache.axis.client.Call.invoke(Call.java:2280)
             at org.apache.axis.client.Call.invoke(Call.java:1741)
             at
org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:156)


Thanks in advance for any help or information that anyone can provide.
I've started to read that Collections aren't directly supported
by JAX-RPC, or SOAP.  Is this true?  It looks like I should start
switching my methods to return arrays instead of collections, but I'd
prefer to find a workaround for now.








This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data 
and other information are not warranted as to completeness or accuracy and 
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan Chase & Co., its
subsidiaries and affiliates.


Reply via email to