日期:2014-05-17  浏览次数:20769 次

无返回值的web服务,为何不能如预期般修改参数值?axis2官网上的POJO例子也不好用
最近在学习axis2,需要一个没返回值的web服务。自己试了一下,不好用,就想着直接用axis2官网上的例子吧。

结果出了同样的问题。

网址:http://axis.apache.org/axis2/java/core/docs/pojoguide.html

例子大致是这样的:
web服务是:
public class WeatherService {

    Weather weather;
    
    public void setWeather(Weather weather){
        this.weather = weather;
    }

    public Weather getWeather(){
        return this.weather;
    }

}


客户端:

public class WeatherService {


    public static void main(String[] args1) throws AxisFault {

        RPCServiceClient serviceClient = new RPCServiceClient();

        Options options = serviceClient.getOptions();

        EndpointReference targetEPR = new EndpointReference(
                "http://localhost:8080/axis2/services/MyServiceTest");
        options.setTo(targetEPR);

        // Setting the weather
        QName opSetWeather =
            new QName("http://server", "setWeather");

        Weather w = new Weather();

        w.setTemperature((float)39.3);
        w.setForecast("Cloudy with showers");
        w.setRain(true);
        w.setHowMuchRain((float)4.5);

        Object[] opSetWeatherArgs = new Object[] { w };

        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
        // Getting the weather
        QName opGetWeather =
            new QName("http://server", "getWeather");

        Object[] opGetWeatherArgs = new Object[] { };
        Class[] returnTypes = new Class[] { Weather.class };
        
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
        
        Weather result = (Weather) response[0];
        
        if (result == null)