环境CXF2.2.6和Spring 2.5。在启动JBOSS上我需要读取CXF属性并更改端点详细信息。从基本阅读开始,它让我认为CXF服务信息类(org.apache.cxf.service.model.ServiceInfo)处理绑定,端点,消息,模式等。
我可以扩展CXFServlet并创建自己的自定义servlet。请告诉我如何在启动时将自己的详细信息提供给Endpoint并覆盖Spring.xml中的内容
答案 0 :(得分:1)
The below Spring bean should do what you wanted. Why do you want to override ServiceInfo class ? Any particular reason ?
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.ServletContextAware;
public class CXFConfig implements InitializingBean{
@Autowired
Bus cxfBus;
@Override
public void afterPropertiesSet() throws Exception {
EndpointImpl endpoint = new EndpointImpl(cxfBus, new GdsAutomationServiceProviderImpl());
endpoint.setAddress("/public/api/service/v1");//WSDL URL
endpoint.setPublishedEndpointUrl(getEndPointAddress());
endpoint.publish();
}
public Bus getCxfBus() {
return cxfBus;
}
public void setCxfBus(Bus cxfBus) {
this.cxfBus = cxfBus;
}
public String getEndPointAddress() {
// Soap address location you need to define here
return "address"
}
@Override
public void setServletContext(ServletContext context) {
context.getServerInfo();
}
}