JiveJdon Community Forums
在线542人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 1 回复 / 1
 发表新帖子   回复该主题贴
jvcoffee

悄悄话
发表文章: 1
注册时间: 2008年03月19日 22:13
xfire 客户端调用webservice的问题 2008年03月19日 22:25 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
接口:
public interface IMainInterface {
public String logining(String userName,String passWord);
public byte[] downloadDisease(String userName,String passWord);
}
客户端: main方法
MainLogin mainLogin = new MainLogin();
String url = "http://localhost:8888/Data_ShareTransaction/services/maininterface";
String userName = "111";
String password = "111";
IMainInterface mainInterface = mainLogin.login(url, userName, password);

DownLoad downLoad = new DownLoad();
downLoad.download(userName, password, mainInterface);
//MainLogin
public class MainLogin {
private static XFireProxyFactory serviceFactory = new XFireProxyFactory();

public IMainInterface login(String url, String username, String password) {
// 建立接口模型
Service mainserverModel = new ObjectServiceFactory()
.create(IMainInterface.class);
String loginURL = url;
IMainInterface mainInterface = (IMainInterface) serviceFactory.create(
mainserverModel, loginURL);
Client client = ((XFireProxy) Proxy
.getInvocationHandler(mainInterface)).getClient();
client.addOutHandler(new DOMOutHandler());
return mainInterface;
}
}
//DownLoad
public class DownLoad {
public void download(String userName, String passWord, IMainInterface mainInterface) {
try {
byte[] bostsByte = mainInterface.downloadDisease(userName, passWord);

putFile(bostsByte,"E:\\testdownload_client\\test1.xml");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}

}
services.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<!-- WebService Impl -->
<bean id="maininterfaceimpl"
class="com.viewhigh.dt.maininter.impl.MainInterfaceImpl" />

<bean id="baseWebService"
class="org.codehaus.xfire.spring.remoting.XFireExporter"
lazy-init="false" abstract="true">
<property name="serviceFactory" ref="xfire.serviceFactory" />
<property name="xfire" ref="xfire" />
</bean>

<bean parent="baseWebService">
<property name="serviceBean" ref="maininterfaceimpl" />
<property name="serviceClass"
value="com.viewhigh.dt.maininter.IMainInterface" />
<property name="name" value="maininterface" /><!-- Web Service名称 -->
<property name="inHandlers">
<list>
<ref bean="domInHandler" />
</list>
</property>
</bean>

<bean id="domInHandler"
class="org.codehaus.xfire.util.dom.DOMInHandler" />
</beans>

运行后抛出异常:
Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
..
at $Proxy0.downloadDisease(Unknown Source)
at client.viewhigh.dt.DownLoad.download(DownLoad.java:22)
at client.viewhigh.dt.TestDownFile.main(TestDownFile.java:23)

为什么这里无法调用service呢?生成的客户端代理找不到真正的实现对象么?
[该贴被jvcoffee于2008-03-19 22:27修改过]
killer

悄悄话
发表文章: 106
注册时间: 2007年07月17日 15:40
re:xfire 客户端调用webservice的问题 2008年03月24日 20:09 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
可能是你的服务没启动,通过IMainInterface mainInterface = mainLogin.login(url, userName, password);
获得的mainInterface 为空
这个主题有 1 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  发贴前查询 标签列表勿重复发表问题

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam