axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David.P...@kp.org
Subject Re: Error running Calculator.jws
Date Sat, 23 Nov 2002 00:47:21 GMT
Hmm, I don't get why you are getting the error. It works fine on my 
system. Sorry I can't be of more help. What version of Axis are you using?





"dumdum 420" <dumdum420@hotmail.com>
11/22/2002 01:53 PM
Please respond to axis-user

 
        To:     axis-user@xml.apache.org
        cc: 
        Subject:        Re: Error running Calculator.jws


That is what I also figured out but if you look at the sample code I was 
wonder stuck and though that may be AXIS makes things work differntly:


I am attaching the samples I have downloaded:

Calulator.java/jws

public class Calculator {
  public int add(int i1, int i2)
  {
    return i1 + i2;
  }


  public int subtract(int i1, int i2)
  {
    return i1 - i2;
  }
}


CalcClient.java

package samples.userguide.example2;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class CalcClient {
   public static void main(String [] args) throws Exception {
       Options options = new Options(args);

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

// Do argument checking
       args = options.getRemainingArgs();

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

       String method = args[0];
       if (!(method.equals("add") || method.equals("subtract"))) {
           System.err.println("Usage: CalcClient <add|subtract arg1 
arg2");
           return;
       }

// Make the call
       Integer i1 = new Integer(args[1]);
       Integer i2 = new Integer(args[2]);

       Service  service = new Service();
       Call     call    = (Call) service.createCall();

       call.setTargetEndpointAddress(new java.net.URL(endpoint));
       call.setOperationName( method );
       call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);
       call.addParameter("op2", XMLType.XSD_INT, ParameterMode.IN);
       call.setReturnType(XMLType.XSD_INT);

       Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });

       System.out.println("Got result : " + ret);
   }
}


I mean if you can solve this for me I can really go ahead to learn this 
stuff.

Regards,

BP






_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail




Mime
View raw message