xfire1.2.3, aegis binding.
The following code causes trouble if one of the byte arrays is of size zero in
the Container class. As a result, either a NPE or an invalid number of
Containers is received on the other side.
The server I tested this simply echos the result ...
Any Idea how to fix this?
Frank
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.transport.Channel;
public class Test {
public static void main (String [] args) {
try {
Class serviceCallback = Callback.class;
ObjectServiceFactory serviceFactory = new ObjectServiceFactory ();
Service serviceModel = serviceFactory.create (serviceCallback);
XFireProxyFactory proxyFactory = new XFireProxyFactory ();
Callback testCallback = (Callback) proxyFactory.create(serviceModel,
"localhost:8080/" + serviceCallback.getName ());
Container [] containers = new Container [2];
System.out.println ("C DSPExternalTest::containerTest");
containers [0] = new Container ();
containers [0].myField = 3;
containers [0].myArray = new byte [0];//causes trouble
containers [1] = new Container ();
containers [1].myField = 4;
containers [1].myArray = new byte [2];
containers = testCallback.containerTest (containers);
System.out.println ("Containers: "+containers.length);
System.out.println ("Containers1: "+containers [0].myField);
System.out.println ("Containers2: "+containers [1].myField);
System.out.println ("Containers1: "+containers [0].myArray.length);
System.out.println ("Containers2: "+containers [1].myArray.length);
} catch (Exception e) {
e.printStackTrace ();
}
}
}
public class Container implements java.io.Serializable {
public Container () {
}
public int myField;
public byte [] myArray;
public int getMyField () {
return myField;
}
public void setMyField (int field) {
myField = field;
}
public byte [] getMyArray () {
return myArray;
}
public void setMyArray (byte [] array) {
myArray = array;
}
}
public interface Callback {
Container [] containerTest (Container [] containers) throws Exception;
}
public class CallbackImpl implements Callback {
public Container [] containerTest (Container [] containers) throws
Exception {
System.out.println ("S CallbackImpl::containerTest");
System.out.println ("Containers: "+containers.length);
System.out.println ("Containers1: "+containers [0].myField);
System.out.println ("Containers2: "+containers [1].myField);
System.out.println ("Containers1: "+containers [0].myArray.length);
System.out.println ("Containers2: "+containers [1].myArray.length);
return containers;
}
}
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email