/*
 BankClient.java
 */import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;public class BankClient
{
public static void main( String[] args ) throws Exception
{
    for(int i=1;i<=3;i++)
    {
        Service service_dep = new Service();
        Call call_dep = ( Call ) service_dep.createCall();        //访问即时发布的BankServer服务,进行存款操作
        
        //设置访问点
        call_dep.setTargetEndpointAddress( "http://localhost:8081/axis/services/BankServer" );        //设置操作名
        call_dep.setOperationName( "deposite" );        //设置入口参数
        call_dep.addParameter( "op1", XMLType.XSD_DOUBLE, ParameterMode.IN );
        call_dep.setReturnType( XMLType.XSD_DOUBLE );        int  dep_val=(int)(Math.random()*10000.0);
        Double dep = new Double( dep_val );        //调用服务
        System.out.println( "存款"+dep + " 元,您的余额为 " +call_dep.invoke( new Object[]{dep} ) + " 元" );
        Service service_wit = new Service();
        Call call_wit= ( Call ) service_wit.createCall();
        
         //访问即时发布的BankServer服务,进行取款操作        //设置访问点
        call_wit.setTargetEndpointAddress( "http://localhost:8081/axis/services/BankServer" );        //设置操作名
        call_wit.setOperationName( "withdraw" );        //设置入口参数
        call_wit.addParameter( "op2", XMLType.XSD_DOUBLE, ParameterMode.IN );
        call_wit.setReturnType( XMLType.XSD_DOUBLE );        int wit_val=(int)(Math.random()*5000);
        Double wit = new Double( wit_val );        //调用服务
        Double return_val=(Double)call_wit.invoke( new Object[]{wit} );        System.out.println( "取款"+wit + " 元,您的余额为 " +return_val + " 元" );
    }
}//end main
}//end BankClient

解决方案 »

  1.   

    /*
    deploy.wsdd
    */<deployment xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="BankServer" provider="java:RPC">
    <parameter name="className" value="BankServer"/>
    <parameter name="allowedMethods" value="*"/>
    </service>
    </deployment>
      

  2.   

    最后在zl_homework3文件夹下建文件:bank.txt
    内容为:
    0.0
    用于程序中保存中间数据。
      

  3.   

    我按文章试了一遍.怎么出现下面异常阿?
    哪位成功试过吗? Exception in thread "main" java.lang.NoClassDefFoundError: javax/wsdl/OperationT
    ype
            at org.apache.axis.description.OperationDesc.<clinit>(OperationDesc.java
    :58)
            at org.apache.axis.client.Call.addParameter(Call.java:948)
            at org.apache.axis.client.Call.addParameter(Call.java:983)
            at BankClient.main(BankClient.java:29)
      

  4.   

    NoClassDefFoundError表明你的classpath中没有这个class,你检查一下你的j2ee.jar包有没有加进classpath!
      

  5.   

    请教一下楼主这个问题
    http://community.csdn.net/Expert/topic/3967/3967581.xml?temp=.6400415