能看到wwdl文档,就说明你得web服务发布成功了,你现在可以开发一个客户端来消耗他了!!!
解决方案 »
- Struts2中,action是如何将数据传给jsp页面
- ofbiz 运用ajax 的url问题
- java.lang.NullPointerException
- 使用extjs的json读取数据时出错,帮忙啊。
- JS
- strus的jar包更改目录!!!在线狂等,亟待解决!!!
- ibatis报ClassNotFoundException: String?
- 求大神推荐
- 应聘上中兴的兄弟帮我分析一下,太难等了
- tigase openfire jabberd 2 聊天的话那种比较靠谱? 微信, QQ, 陌陌都是使用的什么技术实现聊天的?
- 在使用spring+hibernate的时候出现的问题!急!!!
- xfire客户端问题(急)
第二个问题:说明你没有把User Guide中的所有项看完.我这有个例子你照着做一下:
<project name="Tapestry/Spring/Hibernate Example" default="client" basedir=".">
<path id="cp">
<fileset dir="WebContent/WEB-INF/lib/">
<include name="**/*.jar" />
</fileset>
</path>
<taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask" classpathref="cp" />
<target name="client">
<wsgen outputDirectory="client" wsdl="./src/wsdl/XmlService.wsdl" package="com.test.transition" binding="xmlbeans" />
</target>
</project>
http://localhost/services/BookService?WSDL 可以打开说明你的Xfire的服务发布没有问题了
下面要作的是写一个客户端来使用类似下面
Service serviceModel = new ObjectServiceFactory().create(BookService.class);
XFire xfire = XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire);
String serviceUrl = "http://localhost:8080/service/bookService";
BookService client = (BookService) factory.create(serviceModel, serviceUrl);
然后客户端就可以用client .*....来调用服务器方法了
Exception in thread "main" java.lang.IllegalStateException: Service class is not an interface. Please use an interface specify or specify one via a @WebService annotation.public class Client {
public static void main(String arg[]) throws Exception {
Service serviceModel = new ObjectServiceFactory().create(BookService.class); XFire xfire = XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire); String serviceUrl = "http://localhost/servlet/XFireServlet/"; BookService client = (BookService) factory.create(serviceModel, serviceUrl);
}
}
BookService client = (BookService) factory.create(serviceModel, serviceUrl);
来我的BLOG看看,有你需要的东东,另外,你也可以考虑一下用AXIS2开发WEB Services.
http://www.blogjava.net/lbx19822004/
欢迎过来啊!
我看的是晁岳攀写的tutorial,按照他写的我配置了xfire附带的book例子。
问题1:启动服务后输入地址http://localhost/services/ 却显示“找不到网页”
但是输入http://localhost/services/BookService?WSDL 却可以显示这个webservice的wsdl,请问这是怎么会事问题2:而且他里面写到了可以用Wsgen生成客户端代码,但是我搜遍了整个xfire-distribution-1.0文件夹也没看见。请问怎样生成客户端代码-----------------------------------------
你需要输入具体服务的URL,在你的例子中就是http://localhost?services/BookService在xfire的文档里有生成client的例子,你可以看看,但我是自己手写的
Exception in thread "main" java.lang.IllegalStateException: Service class is not an interface. Please use an interface specify or specify one via a @WebService annotation.public class Client {
public static void main(String arg[]) throws Exception {
Service serviceModel = new ObjectServiceFactory().create(BookService.class); XFire xfire = XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire); String serviceUrl = "http://localhost/servlet/XFireServlet/"; BookService client = (BookService) factory.create(serviceModel, serviceUrl);
}
}-----------------------------------开头报的异常已经说的很清楚了,new ObjectServiceFactory().create(BookService.class);
这里传进去的应该是一个接口,如果服务不是接口必须要用@WebService annotation在类的开头声明一下,具体用法请参考文档
谢谢,厉害,我已经明白了,马上结帖