J2ME web service client
Posted
by Wasim
on Stack Overflow
See other posts from Stack Overflow
or by Wasim
Published on 2010-03-25T21:15:02Z
Indexed on
2010/03/25
21:23 UTC
Read the original article
Hit count: 496
Hi all , I started to use the Netbeans 6.8 web service client wizard . I created a web service (.Net web service) witch return an object Data. The Data class , contains fileds with many types : int , string , double , Person object and array of Person object.
I created the J2ME client code through the wizard and every thing seems ok . I see in the Netbeans project the service and the stub . When I try to call my web service method , say Data GetData() ; Then I have a problem with parsing the returned data from the web service and the client data object . As follows : After finishing to call the web service method , in the stub code : public Data helloWorld() throws java.rmi.RemoteException { Object inputObject[] = new Object[] { };
Operation op = Operation.newInstance( _qname_operation_HelloWorld, _type_HelloWorld, _type_HelloWorldResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/HelloWorld" );
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 Data_fromObject((Object[])resultObj);
}
private static Data Data_fromObject( Object obj[] ) {
if(obj == null) return null;
Data result = new Data();
result.setIntData(((Integer )obj[0]).intValue());
result.setStringData((String )obj[1]);
result.setDoubleData(((Double )obj[2]).doubleValue());
return result;
}
I debug the code and in Run time resultObj has one element witc is an array of the Data object , so in parsing the values in the Data_fromObject method it expect many cells like we see in the code obj[0] , obj[1] , obj [2] but in realtime it has obj[0][0] , obj[0][1] , obj[0][2]
What can be the problem , how can check the code generation issue ? Is it a problem with the web service side.
Please help. Thanks in advance...
© Stack Overflow or respective owner