本人按照网上例子制作一个sample,遇到一个问题,当用java编写的客户端调用返回值类型是int的函数时能正确得到返回值,但是调用返回值类型是string的函数时,不能正确得到返回值。以下为服务器端程序源代码:
本人按照网上例子制作一个sample,遇到一个问题,当用java编写的客户端调用返回值类型是int的函数时能正确得到返回值,但是调用返回值类型是string的函数时,不能正确得到返回值。以下为服务器端程序源代码:
/**
* 此处插入类型描述。
* 创建日期:(2005-10-27 10:32:48)
* @author:administrator
*/
import java.util.*;
public class zxjtest {
protected string name="gaga";
protected int age=20;
protected int sex=22;
protected list items=new arraylist();
/**
* zxjtest 构造子注解。
*/
public zxjtest() {
super();
}
public string getname()
{
return name;
}
public int getage()
{
return age;
}
public int getsex()
{
return sex;
}
public list getitems()
{
return items;
}
}
客户端调用的源代码:
string endpoint = "http://myserver:7001/zxjtest.jws";
service service = new service();
call call = (call) service.createcall();
call.settargetendpointaddress(new java.net.url(endpoint));
call.setoperationname("getname");
string ret = (string) call.invoke(new object[] {});
出错的就是最后一句。如果这一句改成调用返回值是int的函数,就不会出错。请问,这是axis的配置的问题吗?如果是,该如何改?
应该不大可能是axis的配置的问题,你调用的是
public string getname()
{
return name;
}
因此返回的是string,这个是没有错误的!……

闽公网安备 35060202000074号