2007-05-31
xfire插件自动生成客户端代码后,调用时报错(已解决)
关键字: WebService
使用eclipes的xfire插件,生成了Webservice的客户端代码
在调用时,报错,具体代码如下
调用client的TestClient代码
HelloWordServiceClient 类中的create0方法中报错,代码如下,错误行已在代码中标出:
报错信息如下:
Exception in thread "main" org.codehaus.xfire.annotations.AnnotationException: Service class cannot be abstract: com.tongtech.bjvsp.client.HelloWordServicePortType
at org.codehaus.xfire.annotations.AnnotationServiceFactory.assertValidImplementationClass(AnnotationServiceFactory.java:268)
at org.codehaus.xfire.annotations.AnnotationServiceFactory.create(AnnotationServiceFactory.java:177)
at org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:284)
at com.tongtech.bjvsp.client.HelloWordServiceClient.create0(HelloWordServiceClient.java:59)
at com.tongtech.bjvsp.client.HelloWordServiceClient.<init>(HelloWordServiceClient.java:26)
at com.tongtech.bjvsp.testclient.TestClient.main(TestClient.java:14)
由于客户端的代码是自动生成,所以不知哪里有问题,还是我在写服务器端代码时出了错?
因为是根据wsdl生成的客户端代码,因此我认为服务端应该不存在问题。
本人对于xfire不是十分熟悉,希望指点一二,谢谢
在调用时,报错,具体代码如下
调用client的TestClient代码
HelloWordServiceClient service=new HelloWordServiceClient();
HelloWordServicePortType type=service.getHelloWordServiceHttpPort();
System.out.println(type.sayHello("123"));
HelloWordServiceClient 类中的create0方法中报错,代码如下,错误行已在代码中标出:
/**
*
*以下为出错的方法
*/
private void create0() {
TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager());
HashMap props = new HashMap();
props.put("annotations.allow.interface", true);
AnnotationServiceFactory asf = new AnnotationServiceFactory(new Jsr181WebAnnotations(), tm, new AegisBindingProvider(new JaxbTypeRegistry()));
asf.setBindingCreationEnabled(false);
service0 = asf.create((com.tongtech.bjvsp.client.HelloWordServicePortType.class), props);//此处出错,提示HelloWordServicePortType不能为抽象类
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://webservicedemo.rubyeye.net", "HelloWordServicePortTypeLocalBinding"), "urn:xfire:transport:local");
}
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0, new QName("http://webservicedemo.rubyeye.net", "HelloWordServiceHttpBinding"), "http://schemas.xmlsoap.org/soap/http");
}
}
报错信息如下:
Exception in thread "main" org.codehaus.xfire.annotations.AnnotationException: Service class cannot be abstract: com.tongtech.bjvsp.client.HelloWordServicePortType
at org.codehaus.xfire.annotations.AnnotationServiceFactory.assertValidImplementationClass(AnnotationServiceFactory.java:268)
at org.codehaus.xfire.annotations.AnnotationServiceFactory.create(AnnotationServiceFactory.java:177)
at org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:284)
at com.tongtech.bjvsp.client.HelloWordServiceClient.create0(HelloWordServiceClient.java:59)
at com.tongtech.bjvsp.client.HelloWordServiceClient.<init>(HelloWordServiceClient.java:26)
at com.tongtech.bjvsp.testclient.TestClient.main(TestClient.java:14)
由于客户端的代码是自动生成,所以不知哪里有问题,还是我在写服务器端代码时出了错?
因为是根据wsdl生成的客户端代码,因此我认为服务端应该不存在问题。
本人对于xfire不是十分熟悉,希望指点一二,谢谢
- 12:45
- 浏览 (1913)
- 评论 (2)
- 分类: WebService相关
- 进入论坛
- 相关推荐
评论
lrh165
2007-11-22
好文章啊,对刚入门的人帮助太大了
ioriyagami808
2007-05-31
自己已解决(问题为xfire版本冲突),具体是这样的
xfire通过eclipse的software的find and install自动从网上找到最新版本的eclipse的xfire插件(http://dist.codehaus.org/xfire/update/).安装完毕后,使用其Code generation from WSDL document生成stub。其客户端生成后,需要选择生成后的置放路径。由于我之前在本地使用xfire建立客户端,xfire建立时导入了xfire1.1的jar包,当我再建立客户端试图测试访问本地webservice服务器端时,也将客户端的生成代码以及运行客户端所需要的jar包一同导入到同一工程中了,即自己建立的服务器端的工程中。此时,客户端运行所导入的xfire1.2.6和服务器端的xfire1.2.5版本不一致,导致以上问题。只是xfire提示的不是很明确
解决办法:
1.先建立一个java project,建立src和lib文件夹
2.使用xfire客户端生成工具生成stub,选择将生成代码置放到新建的工程中src下
3.不知为什么,xfire客户端生成工具生成时不能即时运行,提示缺少jar包,因此,再将commons-codec-1.3.jar和commons-httpclient-3.0.jar只放到lib中并在工程中引用
4.建立clientTest类,调用,测试成功。。
TestStubClient.java源码如下
运行后,显示结果。至此,访问WebService服务成功!!
使用ANT脚本方式生成stub也是一种办法,具体操作见我的另一篇blog
xfire通过eclipse的software的find and install自动从网上找到最新版本的eclipse的xfire插件(http://dist.codehaus.org/xfire/update/).安装完毕后,使用其Code generation from WSDL document生成stub。其客户端生成后,需要选择生成后的置放路径。由于我之前在本地使用xfire建立客户端,xfire建立时导入了xfire1.1的jar包,当我再建立客户端试图测试访问本地webservice服务器端时,也将客户端的生成代码以及运行客户端所需要的jar包一同导入到同一工程中了,即自己建立的服务器端的工程中。此时,客户端运行所导入的xfire1.2.6和服务器端的xfire1.2.5版本不一致,导致以上问题。只是xfire提示的不是很明确
解决办法:
1.先建立一个java project,建立src和lib文件夹
2.使用xfire客户端生成工具生成stub,选择将生成代码置放到新建的工程中src下
3.不知为什么,xfire客户端生成工具生成时不能即时运行,提示缺少jar包,因此,再将commons-codec-1.3.jar和commons-httpclient-3.0.jar只放到lib中并在工程中引用
4.建立clientTest类,调用,测试成功。。
TestStubClient.java源码如下
package com.tongtech.bjvsp.stubClient;
import com.tongtech.webservice.client.HelloWordServiceClient;
import com.tongtech.webservice.client.HelloWordServicePortType;
public class TestStubClient {
public static void main(String []args)
{
HelloWordServiceClient service=new HelloWordServiceClient();
HelloWordServicePortType portType=service.getHelloWordServiceHttpPort();
System.out.println(portType.sayHello("111"));
}
}
运行后,显示结果。至此,访问WebService服务成功!!
使用ANT脚本方式生成stub也是一种办法,具体操作见我的另一篇blog
- 浏览: 11495 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
java Filter的实际应用一 ...
楼主这样还是会乱码吧!http传递过来的编码不是GBK的吧,如果不是GBK的话, ...
-- by 迷失的人 -
java Filter的实际应用一 ...
真是晕倒,为何不使用RequestDistpach跳转?就是是使用sendRed ...
-- by liangguanhui -
java Filter的实际应用一 ...
恩你的更好,改好后这个filter收藏了:) 如果不用绝对路径, else { ...
-- by kakaluyi -
java Filter的实际应用一 ...
看来是 js 不熟啊,用: window.top.location.href ...
-- by myy -
java Filter的实际应用一 ...
out.write("<script>window.parent.pare ...
-- by kakaluyi






评论排行榜