You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-user@ws.apache.org by mi...@netscape.net on 2003/07/05 03:21:48 UTC
stub ClassCastException
Hi,
I have just started using WSIF and am having trouble casting to arrays of objects. I am trying to get results from the following operation (stub created from WSDL with WSDL2Java)
public com.amazon.soap.ProductLine[] blendedSearchRequest(com.amazon.soap.BlendedRequest blendedSearchRequest) throws java.rmi.RemoteException;
The stub call to the above throws this exception:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object;
at $Proxy0.blendedSearchRequest(Unknown Source)
at Run.main(Run.java:58)
If I have the operation being called to a function that returns a single object ie not an array, everything is fine. Does anyone know why this is?
Thanks
mick
Here's the code:
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.WSIFException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import com.amazon.soap.*;
/**
* Simple class that Runs the customfactory sample using a pregenerated stub interface
* To use this class, provide a company stock symbol
* on the command line. WSIF should then invoke the service with this information,
* using the port returned by the custom factory and returning with a recent stockquote. * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
*/
public class Run {
public static void main(String[] args) {
try {
if (args.length != 2)
{
System.exit(1);
}
// create a service factory
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
// parse WSDL
WSIFService service =
factory.getService(
"http://soap-eu.amazon.com/schemas3/AmazonWebServices.wsdl",
null,
null,
"http://soap.amazon.com",
"AmazonSearchPort");
service.mapType(
new QName("http://soap-eu.amazon.com", "ProductLine"),
Class.forName(
"com.amazon.soap.ProductLine"));
// create the stub
// check if the user specified a preferred port
AmazonSearchPort stub = null;
stub = (AmazonSearchPort)
service.getStub(AmazonSearchPort.class);
// do the invocation
// args[1] is the company symbol
BlendedRequest query = new BlendedRequest();
query.setBlended(args[0]);
query.setDevtag("dummy_token");
query.setTag("my query");
query.setLocale(args[1]);
ProductLine[] products = stub.blendedSearchRequest(query);
/* THE LINE ABOVE IS CAUSING CLASSCAST EXCEPTION
System.out.println("Products size is " + products.length);
for (int i = 0; i < products.length; ++i)
{
System.out.println("Index is " + products[i].getProductInfo().getListName());
}
*/
} catch (WSIFException we) {
System.out.println(
"Error while executing sample, received an exception from WSIF; details:");
we.printStackTrace();
} catch (RemoteException re) {
System.out.println(
"Error while executing sample, received an exception due to remote invocation; details:");
re.printStackTrace();
}
catch (ClassNotFoundException ce) {
System.out.println(
"Error while executing sample, could not find required class complexsoap.client.stub.com.cdyne.ws.LatLongReturn; please add it to your classpath; details:");
ce.printStackTrace();
}
}
}
__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
Get AOL Instant Messenger 5.1 free of charge. Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455