xfr
来源:互联网 发布:淘宝权直播间 编辑:程序博客网 时间:2024/05/07 16:05
XFire会借助Spring来解析services.xml,从中提取需要发布为WebService的配置信息。
很多文章介绍到这里就完了,然而当我按照他们所说的启动WebService ,然后通过http://localhost:8080/XFireZhuweiTest/services/MathService?wsdl 来访问服务描述时,却抛出了异常,说services.xml文件不存在--
“org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/xfire/services.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist”。
(7)非常关键的一点,就是这个小难题花费了我将近一天的时间。
在WebContent\WEB-INF目录下新建classes文件夹,然后需要将WebContent下的整个META-INF文件夹剪切到新建的classes文件夹下。
到这里,项目的完整目录结构如下:
(8)在Package Explorer中选中XFireZhuweiTest项目,右键->Run As ->Run On Server,关联到你机器上的TomCat,然后会启动Tomcat,以启动web服务。(注意,在进行此步骤之前,请先停止TomCat)
很多文章介绍到这里就完了,然而当我按照他们所说的启动WebService ,然后通过http://localhost:8080/XFireZhuweiTest/services/MathService?wsdl 来访问服务描述时,却抛出了异常,说services.xml文件不存在--
“org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/xfire/services.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist”。
(7)非常关键的一点,就是这个小难题花费了我将近一天的时间。
在WebContent\WEB-INF目录下新建classes文件夹,然后需要将WebContent下的整个META-INF文件夹剪切到新建的classes文件夹下。
到这里,项目的完整目录结构如下:
(8)在Package Explorer中选中XFireZhuweiTest项目,右键->Run As ->Run On Server,关联到你机器上的TomCat,然后会启动Tomcat,以启动web服务。(注意,在进行此步骤之前,请先停止TomCat)
(9)在IE中输入 http://localhost:8080/XFireZhuweiTest/services/MathService?wsdl 会得到正确的web服务描述文档。
(10)测试刚发布的webService。我使用C#动态调用Web服务:
//C#
string url = "http://localhost:8080/XFireZhuweiTest/services/MathService" ;
object[] args ={1,2} ;
object result = ESFramework.WebService.WebServiceHelper.InvokeWebService(url ,"Add" ,args) ;
MessageBox.Show(result.ToString());
string url = "http://localhost:8080/XFireZhuweiTest/services/MathService" ;
object[] args ={1,2} ;
object result = ESFramework.WebService.WebServiceHelper.InvokeWebService(url ,"Add" ,args) ;
MessageBox.Show(result.ToString());
(关于C#动态调用Web服务,请参见这里)
执行后,弹出对话框,显示结果是3。