[Logo]
Forums Register Login
set return type as array of integer
Hello Gurus
I have a service that returns an array of integer. In client code how do I set the return type of the Call object? Thanks.
call.setReturnType( XMLType.XSD_INT ); ??
Integer []ret = (Integer[]) call.invoke( new Object [] { arraySize}); ??
John
 
Originally posted by John McDonald:
Hello Gurus
I have a service that returns an array of integer. In client code how do I set the return type of the Call object? Thanks.
call.setReturnType( XMLType.XSD_INT ); ??
Integer []ret = (Integer[]) call.invoke( new Object [] { arraySize}); ??
John

Normally I use Axis WSDL2Java to generate javacode which will take care of MANY things.
So why don't you try that to save time (instead of writing urself)?
Hi Balaji,
I am not familiar with that tool. I think I have tried it along with Axis User's guide but get lost. Would you provide me steps in detailed. Thanks.
I have a class Random
public class Random
{
int [] generate(int size)
{
int[] array ....
return array;
}
}
this link might help,
http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html
Best regards,
Thanks Pavan
That sample show paramter setting, not a return type as an array. The other example from this web site shows the return type as a String array by using Response object to catch the result.
...
Response = call.(url, "");
...
But when I tried to run the sample, then it has some casting issue.
http://www.onjava.com/pub/a/onjava/excerpt/jsoap_5/index2.html
Thanks for the info.
John
Hello John,
I thought you would know how to use wsdl2Java from that article. Anyway, can you provide some more info about your problem..
setReturnType() expects a QName as an argument, you could use org.apache.axis.Constants.SOAP_INTEGER or SOAP_INT should work.

as Blaji rightly suggested it 'll be good to use wsdl2java to generate client stubs. It helps, specially when we're learning. It helped me.
Best Regards,
Hello John,
I tried this, It worked for me.

hope this helps.
regards,
Pavan
Thanks.
I can get around by return an array of integer directly by not setting the paramter type. I am fine.
Oh. Let me try that, too. Thanks a lot to all Gurus
[ February 13, 2004: Message edited by: John McDonald ]
I think I need to post this as study case
This is my service:
package p2;

public class Random
{
public int[] generate(int size)
{
int array[] = new int[size];
for (int i = 0 ;i < size; i++)
{
array[i] = (int)(Math.random() * 100);

System.out.println(array[i]);
}

return array;
}
}
my client:
public class Client
{
public static void main(String [] args) throws Exception {
Options options = new Options(args);

String endpoint = "http://localhost:" + options.getPort() +
"/axis/Random.jws";

args = options.getRemainingArgs();

if (args == null || args.length <1) {
System.err.println("Usage: CalcClient <add|subtract> arg1 arg2");
return;
}


Integer i1 = new Integer(args[0]);
String method = "generate";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( method );
int [] array = (int[]) call.invoke( new Object [] { i1 });

for (int i = 0; i < array.length;i++)
{
System.out.println("number " + (i + i) + " " + array[i]);
}
}
}
This is runnabl code. But I don't know why I can't use SOAPmonitor to catch it.
Hello John,
If you're having problems with SOAP Monitor.. this link might help. I know configuring soapmonitor is a bit of a pain.
http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/SoapMonitor
tcpmon could be lot easier.
you could even programmatically print both request and response soap messages, but this has an inherent disadvantage... it does not help when your call fails.

Best Regards,
 
Originally posted by John McDonald:
This is runnabl code. But I don't know why I can't use SOAPmonitor to catch it.

Did you tried the documentation on running the SOAPMonitor applet ?
if not look at the appendix: Using the SOAP Monitor
here
 
Originally posted by Pavan Kumar Panduga:
Hello John,
tcpmon could be lot easier.
Best Regards,

In my experience tcpmon is much easier. Of course it comes built in with WebSphere Studio.
Regards,
Thanks for all. The reason SOAPMonitor did not run because I have had some strange characters in deployment-monitor.wsdd. The error did not get caught at deployment time. You never know to suspect that. This is the case for all wsdd file. At run time your program will yield unpredictable error like No Message Response or do not show up in SOAPMonitor, my case as a typical example.
SOAPMonitor is complex than tcpmon but you don't have to listening port for it. Thanks for all sharing. Very much appreciated.
John
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2017 13:01:46.