1. 程式人生 > >用axis2+Tomcat5.5+Eclipse3.2部署和訪問Web服務

用axis2+Tomcat5.5+Eclipse3.2部署和訪問Web服務

package account;

public class AccountTest {
    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        String endpoint =  "http://localhost:8080/axis2/services/AccountService";
        AccountServiceStub stub = new AccountServiceStub(endpoint);

        AccountServiceStub.SetAccountID set = new AccountServiceStub.SetAccountID();
        set.setId( 2 );
        stub.setAccountID( set );
        
        AccountServiceStub.GetAccountResponse get = stub.getAccount();
        System.out.println( "Current: " + get.get_return() );
        
        AccountServiceStub.Deposit dep = new AccountServiceStub.Deposit();
        dep.setMoney( 120 );
        AccountServiceStub.DepositResponse depRes = stub.deposit( dep );
        System.out.println( "After Deposit 120: " + depRes.get_return() );

        AccountServiceStub.Withdraw draw = new AccountServiceStub.Withdraw();
        draw.setMoney( 50 );
        AccountServiceStub.WithdrawResponse drawRes = stub.withdraw( draw );
        System.out.println( "After Withdraw 50: " + drawRes.get_return() );
        
        AccountServiceStub.GetAccountResponse getLast = stub.getAccount();
        System.err.println( "At last: " + getLast.get_return() );
    }
}
執行結果如下: