CXF编写客户端为什么报这样的错,求大神帮忙解答

黑夜小凡 发布于 2014/10/11 14:54
阅读 3K+
收藏 0

客户端调试代码如下:

package com.oking.ws;


import javax.xml.namespace.QName;


import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.frontend.ClientProxyFactoryBean;


public class TexstClient {
public static void main(String[] args) {
try {
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
String serviceURL;
if (args != null && args.length > 0 && !"".equals(args[0])) {
serviceURL = args[0];
} else {
serviceURL = "http://localhost:8080/sz-dzda/dorado/webservice/UserService.wsdl";
}
factory.setServiceName(new QName("http://www.bstek.com/ws",
"User"));
factory.setAddress(serviceURL);
factory.setWsdlURL(serviceURL);
System.out.println(serviceURL);
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
User client = factory.create(User.class);
System.out.println("Invoke sayHi()....");
System.out.println(client.getUsername());
// System.out.println(client.sayHi(System.getProperty("user.name")));
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}
然后测试就报这样的错了

2014-10-11 14:51:46 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
信息: Creating Service {http://www.bstek.com/ws}User from WSDL: http://localhost:8080/sz-dzda/dorado/webservice/UserService.wsdl
org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://www.bstek.com/ws}User.
at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:171)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:426)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:546)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:156)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:93)
at com.oking.ws.TexstClient.main(TexstClient.java:24)


加载中
0
独孤小败
独孤小败

应该是 ? 号 wsdl 吧

http://localhost:8080/sz-dzda/dorado/webservice/UserService.wsdl

http://localhost:8080/sz-dzda/dorado/webservice/UserService?wsdl

PS: 这代码显示的,怎么都缩进去了...


黑夜小凡
黑夜小凡
这个我是使用BDF2做出来的,它里面就是这样写的
0
tonghui348
tonghui348
这个错误我也遇见了,请问您是否解决?能否告知解决方法?谢谢。
0
Nodzhou
Nodzhou

请问如何解决?

 

返回顶部
顶部