我用Xfire webservice,客户端调用后,产生的是这样的内容,而我想的是在客户端得到一个javabean对象的。这里必须得自己想办法转吗???
<out xmlns="user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:UserInfo xmlns:ns1="http://entity.zhang.com">
<birthday xmlns="http://entity.zhang.com">123</birthday>
<email xmlns="http://entity.zhang.com">[email protected]</email>
<login xmlns="http://entity.zhang.com">123</login>
<nation xmlns="http://entity.zhang.com">中国</nation>
<nativeplace xmlns="http://entity.zhang.com">123</nativeplace>
<pw xmlns="http://entity.zhang.com">123</pw>
<sex xmlns="http://entity.zhang.com">1</sex>
<telephone xmlns="http://entity.zhang.com">12345678</telephone>
<userid xmlns="http://entity.zhang.com">1</userid>
<username xmlns="http://entity.zhang.com">123</username>
</ns1:UserInfo>
</out>
<out xmlns="user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:UserInfo xmlns:ns1="http://entity.zhang.com">
<birthday xmlns="http://entity.zhang.com">123</birthday>
<email xmlns="http://entity.zhang.com">[email protected]</email>
<login xmlns="http://entity.zhang.com">123</login>
<nation xmlns="http://entity.zhang.com">中国</nation>
<nativeplace xmlns="http://entity.zhang.com">123</nativeplace>
<pw xmlns="http://entity.zhang.com">123</pw>
<sex xmlns="http://entity.zhang.com">1</sex>
<telephone xmlns="http://entity.zhang.com">12345678</telephone>
<userid xmlns="http://entity.zhang.com">1</userid>
<username xmlns="http://entity.zhang.com">123</username>
</ns1:UserInfo>
</out>
那Xfire webservice 也没怎么好用啊??
我在网上看到很多的例子,感觉都是有问题,他们根本上没有分布在2个应用上测试,要么就是把这个应用给打包放到那个应用那边。哎,高手,教教怎么做吧!!!!!
workService = (IWorkService) proxyFactory.create(serviceModel,
"http://" + serverIp + ":" + serverPort
+ "/bookmgrs/service/IWorkService");workService就是服务接口
workService = (IWorkService) proxyFactory.create(serviceModel,
"http://" + serverIp + ":" + serverPort
+ "/bookmgrs/service/IWorkService");workService就是服务接口
http://blog.csdn.net/kj_zx19854/archive/2008/12/19/3560908.aspx
看不到图片的话。发邮件我发文档给你[email protected]
<out xmlns="user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:UserInfo xmlns:ns1="http://entity.zhang.com">
<birthday xmlns="http://entity.zhang.com">123 </birthday>
<email xmlns="http://entity.zhang.com">[email protected] </email>
<login xmlns="http://entity.zhang.com">123 </login>
<nation xmlns="http://entity.zhang.com">中国 </nation>
<nativeplace xmlns="http://entity.zhang.com">123 </nativeplace>
<pw xmlns="http://entity.zhang.com">123 </pw>
<sex xmlns="http://entity.zhang.com">1 </sex>
<telephone xmlns="http://entity.zhang.com">12345678 </telephone>
<userid xmlns="http://entity.zhang.com">1 </userid>
<username xmlns="http://entity.zhang.com">123 </username>
</ns1:UserInfo>
</out>这个是我客户端去得的一组数据,也就是一个完整的用户信息,现在我想取其中的email,
我用的dom4j来解析这个xml数据。
可是我发现在取这个元素“ns1:UserInfo”的时候,始终不行,而如果我把他改为"UserInfo"或是其它的,只要不是有分割符的都可以,请问该怎么解决啊,也就是xml中的元素有分隔符该怎么处理????
1、使用xml的话,需要确定数据邦定技术,常用的有xmlbeans、jaxb等等,然后客户端使用相同的邦定技术即可
2、(推荐)使用json,服务器端对数据使用json封装,然后在客户端通过json解析并于javabean映射即可。这样做的好处是json提供多语言支持,xml的数据邦定在跨语言处理的时候会有些麻烦。