You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ahmed Al-Obaidy <ah...@yahoo.com> on 2010/05/05 09:02:22 UTC

Web Service return arrays of Object[] always

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: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org