初学AXIS2 按照网上的教程操作遇到个问题,客户端无法接收服务端返回的Int数组。
网站教程地址:http://blog.csdn.net/jojoy_828/archive/2007/12/02/1911380.aspx
在服务端的业务类里 我自己加了一个方法,代码如下:
package account;import java.util.ArrayList;public class AccountOper {
private static int[] fund = {10000, 500, 700, 5800};
public static int accountID = 0;//in {0,1,2,3} public boolean setAccountID( int id ) {
if(id < 0 || id > fund.length)
return false;
this.accountID = id;
return true;
}
public boolean checkInput(int money)
{
if (money > fund[accountID]) {
return false;
} else {
return true;
}
} //deposit
public int deposit(int money)
{
fund[accountID] = fund[accountID] + money;
return fund[accountID];
} //withdraw
public int withdraw(int money) {
if (checkInput(money)) {
fund[accountID] = fund[accountID] - money;
}
return fund[accountID];
} public int getAccount() {
return fund[accountID];
}
//问题在这个方法
public int[] getInt(){
int[] m=new int[]{1,2};
return m;
}
}
******************************************************
客户端代码:
package account;import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;import javax.xml.rpc.Call;
import javax.xml.ws.Response;import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.databinding.utils.BeanUtil;
import org.apache.axis2.util.StreamWrapper;public class TestMain { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
String endpoint = "http://localhost:8080/axis2/services/AccountService";
try{
AccountOperStub stub = new AccountOperStub(endpoint); AccountOperStub.SetAccountID set = new AccountOperStub.SetAccountID();
set.setId( 1 );
stub.setAccountID( set );
AccountOperStub.GetAccountResponse get = stub.getAccount();
System.out.println( "您的余额: " + get.get_return() );
//此处不知道该怎么写代码来接收服务端返回的数组。
}catch(Exception e){
//throws e;
}
}}
*********************************************************************
麻烦各位CSDN的大哥们帮个忙了,急!!!!!!!!!!!!!
网站教程地址:http://blog.csdn.net/jojoy_828/archive/2007/12/02/1911380.aspx
在服务端的业务类里 我自己加了一个方法,代码如下:
package account;import java.util.ArrayList;public class AccountOper {
private static int[] fund = {10000, 500, 700, 5800};
public static int accountID = 0;//in {0,1,2,3} public boolean setAccountID( int id ) {
if(id < 0 || id > fund.length)
return false;
this.accountID = id;
return true;
}
public boolean checkInput(int money)
{
if (money > fund[accountID]) {
return false;
} else {
return true;
}
} //deposit
public int deposit(int money)
{
fund[accountID] = fund[accountID] + money;
return fund[accountID];
} //withdraw
public int withdraw(int money) {
if (checkInput(money)) {
fund[accountID] = fund[accountID] - money;
}
return fund[accountID];
} public int getAccount() {
return fund[accountID];
}
//问题在这个方法
public int[] getInt(){
int[] m=new int[]{1,2};
return m;
}
}
******************************************************
客户端代码:
package account;import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;import javax.xml.rpc.Call;
import javax.xml.ws.Response;import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.databinding.utils.BeanUtil;
import org.apache.axis2.util.StreamWrapper;public class TestMain { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
String endpoint = "http://localhost:8080/axis2/services/AccountService";
try{
AccountOperStub stub = new AccountOperStub(endpoint); AccountOperStub.SetAccountID set = new AccountOperStub.SetAccountID();
set.setId( 1 );
stub.setAccountID( set );
AccountOperStub.GetAccountResponse get = stub.getAccount();
System.out.println( "您的余额: " + get.get_return() );
//此处不知道该怎么写代码来接收服务端返回的数组。
}catch(Exception e){
//throws e;
}
}}
*********************************************************************
麻烦各位CSDN的大哥们帮个忙了,急!!!!!!!!!!!!!
int[] intArray = (int[]) rps.get_return();