I have a small souci with the passing of an array of pojos my webservice. Axis version 1.5.1 with Eclipse and Tomcat. The object in question takes this form: class AnObject { private String name; private String title; private int type; //... public AnObject(){} public AnObject( String name ) { this.name = name; } public void setName( String name ) { this.name = name; } public String getName() { return name; } public void setTitle( String title ) { this.title = title; } public String getTitle() { return title; } public void setType( int type ) { this.type = type; } public int getType() { return type; } public String toString() { return getTitle(); }}
The web service in question has a function: public void doStuff( SessionId sessionId, AnObject[] theObjects ){ //....} My problem comes when I enter this function: The array of objects I have is not the same as the array passed. The read objects are: AnObject[0] name = "title 1" title = null type = 0 ... AnObject[1] name = "title 2" title = null type = 0 ... Now the reason this happens is the following: In the class org.apache.axis2.databinding.utils.BeanUtil the deserialize() method reads my array perfectly. The ProcessElement() method builds the object just as I expect them.However, when it finishes constructing a list of AnObjects, it then attempts to build an array AnObject[] calling ConverterUtil.convertToArray( Class, List )Here, quite disastrously it calls the static method ConvertToArbitraryObjectArray() which takes my array of objects and does the following to them. Array.set(returnArray, i, getObjectForClass( baseArrayClass, o.toString())); getObjectForClass(): Constructor stringConstructor = clazz.getConstructor(new Class[] { String.class }); return stringConstructor.newInstance(new Object[] { value }); So by cloning my original objects, and calling the one arg constructor. There might be a good reason for why it attempts to clone perfectly constructed objects, but for me this is an unmitigated disaster.I could potentially get around this by having AnObject implement the ADBBean interface, and hence not pass through this code, and execute the correct: try { objectList.toArray((Object[])returnArray); } catch (Exception e) { //we are over with alternatives - throw the //converison exception throw new ObjectConversionException(e); } But this is not really an option. Having a dependency on the axis.jar will set off my twitch. Is there a work around for this, or am I doing something incorrectly?Is there a work around for this that won't start me twitching? Regards,James.