I have a web service function that return array of Vehicle class.
I user ServiceClient to consume the service on the fly.
The problem is BeanUtil.deserialize() return Object[] instead of Vehicle[]. And
the returned array can not be casted to Vehicle[] directly.
currently I build a new Array of Vehicle class, and cast each element of the
Object[] separately. But there should be a more elegant way?
The following is the client code:
ServiceClient client = new ServiceClient();
Options opts = new Options();
opts.setTo(new EndpointReference(SERVICE));
opts.setAction("urn:getVehicles");
client.setOptions(opts);
OMElement element = null;
XMLStreamReader reader = BeanUtil.getPullParser(parent);
StreamWrapper parser = new StreamWrapper(reader);
StAXOMBuilder stAXOMBuilder = OMXMLBuilderFactory.createStAXOMBuilder(
OMAbstractFactory.getOMFactory(), parser);
element = stAXOMBuilder.getDocumentElement();
element.declareDefaultNamespace(NAMESPACE);
OMElement result = client.sendReceive(element);
Object obj = BeanUtil.deserialize(result,
new Object[] { Vehicle.class },
new DefaultObjectSupplier());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]