問題一: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);
即可解決