1、安装tomcat
2、安装CXF





@Configuration
public class CxfConfig { @Autowired
private Bus bus; //private SpringBus bus;
@Autowired
private CommonService commonService; // 配置CXF服务发布,默认服务是在host:port/services/发布地址
// 访问地址 http://127.0.0.1:8080/Service/common?wsdl
@Bean
public Endpoint another_endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, commonService);
endpoint.publish("/common"); //发布地址
return endpoint;
}
// 访问地址 http://127.0.0.1:8080/Service/hello?wsdl
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new HelloServiceImpl());
endpoint.publish("/hello"); //发布地址
return endpoint;
}

问题:
1、与Spring整合问题
Caused by: org.apache.cxf.ws.policy.PolicyException: These policy alternatives can not be satisfied:
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SupportingTokens
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}UsernameToken
at org.apache.cxf.ws.policy.AssertionInfoMap.checkEffectivePolicy(AssertionInfoMap.java:166)
at org.apache.cxf.ws.policy.PolicyVerificationInInterceptor.handle(PolicyVerificationInInterceptor.java:101)
解决方法
esb-server.xml配置增加
<cxf:bus>
<cxf:properties>
<entry key="org.apache.cxf.message.Message.ENCODING" value="UTF-8"/>
</cxf:properties>
<cxf:features>
<cxf:logging/>
<p:policies enabled="false" />
</cxf:features>
</cxf:bus>
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
SpringBus springBus = new SpringBus();
WSPolicyFeature wpf = new WSPolicyFeature();
wpf.setEnabled(false);
Collection<Feature> features = springBus.getFeatures();
features.add(wpf);
return springBus;
}