NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
spacewatcher
Joined: 11 Oct 2009 Posts: 15
|
Posted: Sat Oct 17, 2009 10:31 pm Post subject: java.lang.ClassCastException when run mobile web service clients [Bug?] |
|
|
Hello !!
I wrote a web service in Netbeans 6.7, and two clients for it, one web client, and a mobile client. The web client works fine, but the mobile clients does not work when i use complex types in the methods. When i generate the mobile client on Netbeans 6.5, it works.
I found that the error is in the Stub class generated by the IDE:
The "complex type" :
| Code: | public class IGCAddress
{
public String fullname;
public String id;
public String nbhoodL;
public String nbhoodR;
public int height;
} |
The service method:
| Code: | @WebMethod(operationName = "getTestAddress")
public IGCAddress[] getTestAddress() { ... return array }
|
The 6.7 method, in IGCService_Stub class:
| Code: |
public igcAddress[] getAddress(String streetname, int height) throws java.rmi.RemoteException {
Object inputObject[] = new Object[] {
streetname,
new Integer(height)
};
Operation op = Operation.newInstance( _qname_operation_getAddress, _type_getAddress, _type_getAddressResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
Object resultObj;
try {
resultObj = op.invoke( inputObject );
} catch( JAXRPCException e ) {
Throwable cause = e.getLinkedCause();
if( cause instanceof java.rmi.RemoteException ) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}
return igcAddress_ArrayfromObject((Object[]) resultObj);
} |
The 6.5 method, in IGCService_Stub class:
| Code: |
public igcAddress[] getAddress(String streetname, int height) throws java.rmi.RemoteException {
Object inputObject[] = new Object[] {
streetname,
new Integer(height)
};
Operation op = Operation.newInstance( _qname_operation_getAddress, _type_getAddress, _type_getAddressResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "" );
Object resultObj;
try {
resultObj = op.invoke( inputObject );
} catch( JAXRPCException e ) {
Throwable cause = e.getLinkedCause();
if( cause instanceof java.rmi.RemoteException ) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}
return igcAddress_ArrayfromObject((Object[])((Object[]) resultObj)[0]);
}
|
Note that differ only in the last line (return line). If you change the last line in the 6.7 method
by the last line in the 6.5 method, then it works. If not, this is the error:
java.lang.ClassCastException
at igcservice.IGCService_Stub.igcAddress_ArrayfromObject(IGCService_Stub.java:175)
at igcservice.IGCService_Stub.getAddress(IGCService_Stub.java:166)
at Displayable1.invokeServlet(Displayable1.java:93)
at Displayable1$1.run(Displayable1.java:66)
The line is:
| Code: | private static igcAddress[] igcAddress_ArrayfromObject( Object obj[] ) {
if(obj == null) return null;
igcAddress result[] = new igcAddress[obj.length];
for( int i = 0; i < obj.length; i++ ) {
result[i] = new igcAddress();
Object[] oo = (Object[]) obj[i];
result[i].setFullname((String )oo[0]); //<----------- HERE!!
result[i].setId((String )oo[1]);
result[i].setNbhoodL((String )oo[2]);
result[i].setNbhoodR((String )oo[3]);
result[i].setHeight(((Integer )oo[4]).intValue());
}
return result;
} |
I think it's a bug. Someone else with this problem?
Thanks!!
PD: I do not speak very good English
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|