Axis2 1.3 POJO guide里的例子通过Axis2的Service Achiever插件发布,调用服务问题!

xpoofing 2008-04-20 04:05:40
axis2 bin包里的源码使用ant生成的arr发布使用客户端调用服务正常,输出:
Temperature : 39.3
Forecast : Cloudy with showers
Rain : true
How much rain (in inches) : 4.5

而使用Axis2的Service Achiever插件生成的arr发布调用失败,输出:
Weather didn't initialize!//

package sample.pojo.data;

public class Weather {
float temperature;
String forecast;
boolean rain;
float howMuchRain;

public void setTemperature(float temp) {
temperature = temp;
}

public float getTemperature() {
return temperature;
}

public void setForecast(String fore) {
forecast = fore;
}

public String getForecast() {
return forecast;
}

public void setRain(boolean r) {
rain = r;
}

public boolean getRain() {
return rain;
}

public void setHowMuchRain(float howMuch) {
howMuchRain = howMuch;
}

public float getHowMuchRain() {
return howMuchRain;
}
}

//这个是服务

package sample.pojo.service;

import sample.pojo.data.Weather;


public class WeatherService {
Weather weather;

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

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

//这是客户端

package sample.pojo.rpcclient;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

import sample.pojo.data.Weather;

import javax.xml.namespace.QName;


public class WeatherRPCClient {
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/WeatherService");

options.setTo(targetEPR);

// Setting the weather
QName opSetWeather = new QName("http://service.pojo.sample",
"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://service.pojo.sample",
"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) {
System.out.println("Weather didn't initialize!");

return;
}

// Displaying the result
System.out.println("Temperature : " +
result.getTemperature());
System.out.println("Forecast : " +
result.getForecast());
System.out.println("Rain : " + result.getRain());
System.out.println("How much rain (in inches) : " +
result.getHowMuchRain());
}
}
...全文
134 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
颐和园 2008-12-23
  • 打赏
  • 举报
回复
请问是怎么解决的?希望楼主能共享下。
xpoofing 2008-04-26
  • 打赏
  • 举报
回复
已经解决了
xpoofing 2008-04-24
  • 打赏
  • 举报
回复
在eclipse jee环境下,通过集成的web service工具从java bean创建服务,当我为bean的属性设置了默认值时,通过web服务get属性值时结果是正确的,就是set属性值没有成功,是不是invokeRobust有什么要注意的,API对invokeRobust也没有清楚的描述,不知道有谁了解一点?
xpoofing 2008-04-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yojiwei 的回复:]
会不会是某些个包没有倒进去?
沙发坐下,顶了。
[/Quote]
倒到哪里去?
yojiwei 2008-04-22
  • 打赏
  • 举报
回复
会不会是某些个包没有倒进去?
沙发坐下,顶了。

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧