使用eclipes的xfire插件,生成了Webservice的客户端代码
在调用时,报错,具体代码如下
调用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不是十分熟悉,希望指点一二,谢谢