• Post Reply Bookmark Topic Watch Topic
  • New Topic

set return type as array of integer

 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
}
 
Pavan Panduga
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this link might help,
http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html
Best regards,
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pavan Panduga
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Pavan Panduga
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello John,
I tried this, It worked for me.

hope this helps.
regards,
Pavan
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pavan Panduga
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Howard Kushner
author
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!