No write method for property问题的解决

public class Event {
	
	private String eventid;
	private String eventname;
<span style="white-space:pre">	</span>//0,1
	private String type;
	public String getEventid() {
		return eventid;
	}
	public void setEventid(String eventid) {
		this.eventid = eventid;
	}
	public String getEventname() {
		return eventname;
	}
	public void setEventname(String eventname) {
		this.eventname = eventname;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
<span style="white-space:pre">	</span>
<span style="white-space:pre">	</span>public int <span style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px; white-space: pre; background-color: rgb(250, 250, 250);">getTypeInt(){</span>
<span style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px; white-space: pre; background-color: rgb(250, 250, 250);"><span style="white-space:pre">		<span class="keyword" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px; white-space: pre; background-color: rgb(250, 250, 250); color: rgb(127, 0, 85); font-weight: bold;">return</span><span style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px; white-space: pre; background-color: rgb(250, 250, 250);"> Integer.parseInt(type);</span></span></span>
<span style="background-color: rgb(250, 250, 250); font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px;"><span style="white-space:pre">	</span>}</span>
</pre><pre name="code" class="html"><span style="white-space:pre">	</span>	

}


使用xfire的websevice调用时,会将对象与xml进行捆绑。整体的大概流程是:

1、 通过传递对象的get、is方法获取需要传递的属性(属性私有)

2、 与xml捆绑并网络传输

3、 解绑参数,并调用set方法将参数设置进去。

 

因此,虽然getTypeInt()只是一个方法,还是会被误以为是属性并与xml进行捆绑,在客户端当做属性进行解绑,并调用setTypeInt进行设置时,发现没有该方法,就跑出了一个异常。

 

 

在不改动源代码的情况下,我们在使用xfire中就得绕过这个坑:

1、如果你需要传递某些属性,一定要同时定义它的get、set方法,否则会丢失这些信息

2、自定义的方法名不要使用get打头的方法名,否则会被识别为属性并调用set设值,这样就会抛错了

解决办法:现在只需要将确实的属性和方法,补充上去就可以了。

这是我遇到的问题,以及解决办法,希望对大家有所帮助

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值