问题一:Could not find destination factory for transport
需要加入cxf-rt-transports-http-jetty的jar包,以下是maven中的配置
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>2.3.3</version> </dependency>
问题二:No operation was found with the name {。。。} ,原因是在当前默认的命名空间中找不到请求的操作方法;
解决方法:如果报的是找不到接口,那么在实现类上配置
@WebService(endpointInterface = "com.cxf.hello.IHelloService",targetNamespace = "http://hello.cxf.com/" )
public class HelloServiceImpl implements IHelloService{
......
}
其中targetNamespace中的路径为包名的逆序排列;如果报的是找不到相关的javabean类,那么在相关的类上配置
@XmlType(name = "Hello",namespace = "bean.cxf.com")
public class Hello{
......
}
该命名空间指向在客户端调用的时候的对应的bean所在包的逆序(用于将当前的命名空间指向接口,需要重新发布公共接口)
问题三:A cycle is detected in the object graph. This will cause infinitely deep XML,原因是在两个对象中又互相引用了彼此,比如:
public class UserLogin{
private int userId;
private String userName;
private String userPassword;
private UserInfo info;
.........
}
public class UserInfo {
private int userId;
private String sex;
private String address;
private UserLogin login;
.......
}
此时需要在类的一端调用中使用@XmlTransient注解(用于get方法上),该注解的作用是不将该属性解析成Xml文件中的元素
问题四:
java.net.SocketTimeoutException: Read timed out
在客户端的spring中的配置如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd" default-autowire="byName"> <http-conf:conduit name="{http://investigation.cxf.spiss.sh.org/}CxfInvestServiceImplService.http--conduit"> <http-conf:client ConnectionTimeout="500000" ReceiveTimeout="600000"/> </http-conf:conduit> </beans>然后在客户端 创建了client之后,接着键入如下代码:
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(600000);//连接超时时间
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(600000);//接收超时时间
http.setClient(httpClientPolicy);
即可解决