xfire 客戶端呼叫webservice的問題
介面:
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呢?生成的客戶端代理找不到真正的實現物件麼?
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修改過]
相關文章
- webService 客戶端呼叫 axis2Web客戶端
- CXF建立webservice客戶端和服務端Web客戶端服務端
- 【知識積累】伺服器端獲取客戶端的IP地址(當客戶端呼叫由Axis開發的WebService)伺服器客戶端Web
- 生成Webservice客戶端的4中方法Web客戶端
- JAVA FTP客戶端問題JavaFTP客戶端
- TSM客戶端的排程問題客戶端
- 客戶端tnsping不通問題客戶端
- xfire+spring整合webserviceSpringWeb
- 以 Laravel 的方式呼叫 ai 客戶端LaravelAI客戶端
- MySQL客戶端中文亂碼問題。MySql客戶端
- Java建立WebService服務及客戶端實現JavaWeb客戶端
- oracle客戶端同sap衝突的問題Oracle客戶端
- .net客戶端呼叫activeMQ程式碼客戶端MQ
- 使用cmd webservice wsdl網址生成客戶端程式碼Web客戶端
- Java建立WebService服務及客戶端實現(轉)JavaWeb客戶端
- Mac下SVN客戶端CornerStone使用問題Mac客戶端
- WebSphere客戶端遷移的一般問題Web客戶端
- CouchBase C 客戶端介面呼叫例項客戶端
- 請幫我看看呼叫webservice的問題謝謝!Web
- C# 獲取客戶端資訊 /asp.net/WebService/WebFormC#客戶端ASP.NETWebORM
- 【轉載】webservice框架xfire和axis的比較Web框架
- wsus客戶端安裝時的許可權問題客戶端
- .Net Remoting服務端與客戶端呼叫示例REM服務端客戶端
- 在客戶端儲存對EJB的遠端呼叫是否可行?客戶端
- java使用axis 呼叫WCF webservice問題請教JavaWeb
- 在指令碼中呼叫cassandra客戶端命令指令碼客戶端
- 【原創】webservice xfire框架例項筆記Web框架筆記
- 客戶端安裝虛擬機器問題解答?客戶端虛擬機
- 客戶端(windows)訪問FTP伺服器遇到的問題(總結)客戶端WindowsFTP伺服器
- 客戶端無法連線資料庫的小問題客戶端資料庫
- WebSphere客戶端遷移的常見問題解決二Web客戶端
- spring mina整合(客戶端進行呼叫)Spring客戶端
- 遠端客戶端 訪問 ASM 例項客戶端ASM
- CXF入門教程(3) -- webService客戶端開發步驟詳解Web客戶端
- 使用WebService釋出soap介面,並實現客戶端的https驗證Web客戶端HTTP
- MQTT 客戶端應用及常見問題(C#)MQQT客戶端C#
- Nginx配置ssl_client_certificate客戶端認證問題Nginxclient客戶端
- 怎樣在websphere環境外的客戶端呼叫webshphere的ejb?Web客戶端