CXFBusFactory busFactory = new CXFBusFactory();
Bus bus = busFactory.createBus();
final TLSClientParameters clientParameters = new TLSClientParameters();
// 忽略域名检查
clientParameters.setDisableCNCheck(true);
bus.setExtension(new Configurer() {
@SuppressWarnings("deprecation")
public void configureBean(Object beanInstance) {
if (beanInstance instanceof HTTPConduit) {
HTTPConduit conduit = (HTTPConduit) beanInstance;
conduit.setTlsClientParameters(clientParameters);
conduit.setBasicAuthSupplier(new HttpBasicAuthSupplier() {
@Override
public UserPass getPreemptiveUserPass(String conduitName, URL currentURL, Message message) {
return super.createUserPass("账号", "密码");
}
@Override
public UserPass getUserPassForRealm(String conduitName, URL currentURL, Message message, String realm) {
return super.createUserPass("账号", "密码");
}
});
}
}
public void configureBean(String name, Object beanInstance) {
configureBean(beanInstance);
}
}, Configurer.class);
BusFactory.setThreadDefaultBus(bus);
JaxWsProxyFactoryBean factorys = new JaxWsProxyFactoryBean();
factorys.setBus(bus);
factorys.setServiceClass(SamServicePortType.class);
factorys.setAddress("接口地址");
factorys.setServiceName(new QName("命名空间地址", "名称"));
Bus bus = busFactory.createBus();
final TLSClientParameters clientParameters = new TLSClientParameters();
// 忽略域名检查
clientParameters.setDisableCNCheck(true);
bus.setExtension(new Configurer() {
@SuppressWarnings("deprecation")
public void configureBean(Object beanInstance) {
if (beanInstance instanceof HTTPConduit) {
HTTPConduit conduit = (HTTPConduit) beanInstance;
conduit.setTlsClientParameters(clientParameters);
conduit.setBasicAuthSupplier(new HttpBasicAuthSupplier() {
@Override
public UserPass getPreemptiveUserPass(String conduitName, URL currentURL, Message message) {
return super.createUserPass("账号", "密码");
}
@Override
public UserPass getUserPassForRealm(String conduitName, URL currentURL, Message message, String realm) {
return super.createUserPass("账号", "密码");
}
});
}
}
public void configureBean(String name, Object beanInstance) {
configureBean(beanInstance);
}
}, Configurer.class);
BusFactory.setThreadDefaultBus(bus);
JaxWsProxyFactoryBean factorys = new JaxWsProxyFactoryBean();
factorys.setBus(bus);
factorys.setServiceClass(SamServicePortType.class);
factorys.setAddress("接口地址");
factorys.setServiceName(new QName("命名空间地址", "名称"));
factorys.setWsdlURL("接口地址");
object对象 对象=(强转对象)factorys.create();
用的jar包是xerces-2.9.0.jar,XmlSchema-1.4.7.jar,cxf-2.3.7.jar。备用wsdl4j-1.6.2-fixed.jar