use of org.apache.cxf.transport.http.HTTPConduit in project dubbo by alibaba.
the class WebServiceProtocol method doRefer.
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
proxyFactoryBean.setAddress(url.setProtocol("http").toIdentityString());
proxyFactoryBean.setServiceClass(serviceType);
proxyFactoryBean.setBus(bus);
T ref = (T) proxyFactoryBean.create();
Client proxy = ClientProxy.getClient(ref);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
policy.setReceiveTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
conduit.setClient(policy);
return ref;
}
use of org.apache.cxf.transport.http.HTTPConduit in project opennms by OpenNMS.
the class TsrmTicketerPlugin method getService.
private SHSIMPINCPortType getService() {
final SHSIMPINC service = new SHSIMPINC();
port = service.getSHSIMPINCSOAP12Port();
final Client cxfClient = ClientProxy.getClient(port);
try {
cxfClient.getRequestContext().put(Message.ENDPOINT_ADDRESS, getProperties().getProperty("tsrm.url"));
final HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
String stictSSL = getProperties().getProperty("tsrm.ssl.strict");
if (!Boolean.parseBoolean(stictSSL)) {
LOG.debug("Disabling strict SSL checking.");
// Accept all certificates
final TrustManager[] simpleTrustManager = new TrustManager[] { new AnyServerX509TrustManager() };
final TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setTrustManagers(simpleTrustManager);
tlsParams.setDisableCNCheck(true);
http.setTlsClientParameters(tlsParams);
}
} catch (IOException e) {
LOG.error("Unable to load tsrm properties ", e);
}
// Log incoming and outgoing requests
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
cxfClient.getInInterceptors().add(loggingInInterceptor);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
cxfClient.getOutInterceptors().add(loggingOutInterceptor);
return port;
}
use of org.apache.cxf.transport.http.HTTPConduit in project uavstack by uavorg.
the class DoTestJaxWSHook method main.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
ConsoleLogger cl = new ConsoleLogger("test");
cl.setDebugable(true);
UAVServer.instance().setLog(cl);
UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR, ServerVendor.TOMCAT);
Map config = new HashMap();
Map adapts = JSONHelper.toObject("{\"org.apache.cxf.frontend.ClientProxy\":{\"getClient\":{args:[\"java.lang.Object\"],target:0}}}", Map.class);
config.put("adapts", adapts);
JaxWSHookProxy jp = new JaxWSHookProxy("test", config);
jp.doInstallDProxy(null, "test");
TestService_Service s = new TestService_Service();
TestService ts = s.getTestServicePort();
// 设置客户端的配置信息,超时等.
Client proxy = ClientProxy.getClient(ts);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
// 连接服务器超时时间
policy.setConnectionTimeout(30000);
// 等待服务器响应超时时间
policy.setReceiveTimeout(30000);
conduit.setClient(policy);
ts.echo();
try {
ts.echoFault();
} catch (Exception e) {
e.printStackTrace();
}
Dispatch<SOAPMessage> d = s.createDispatch(new QName("http://service.fat.monitorframework.creditease.com/", "TestServicePort"), SOAPMessage.class, Mode.MESSAGE);
try {
SOAPMessage msg = MessageFactory.newInstance().createMessage();
d.invoke(msg);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("--------------->CECXFClient");
CECXFClient client = new CECXFClient(TestService_Service.class, TestService.class, TestService_Service.TestServicePort);
client.setConnectTimeout(30000);
client.setReceiveTimeout(30000);
try {
client.invoke("echo", null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project tesb-rt-se by Talend.
the class RuntimeESBConsumer method getClient.
private Client getClient() throws BusException, EndpointException {
if (client == null) {
client = clientFactory.create();
if (null != authorizationPolicy) {
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setAuthorization(authorizationPolicy);
}
}
return client;
}
use of org.apache.cxf.transport.http.HTTPConduit in project tesb-rt-se by Talend.
the class MonitoringServiceFullTest method testSendEvents.
// @Before
// public void setUp() throws Exception {
// executeSqlScript("create.sql", true);
// }
@Test
public void testSendEvents() throws PutEventsFault, MalformedURLException, URISyntaxException {
Client client = ClientProxy.getClient(monitoringService);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy clientConfig = new HTTPClientPolicy();
clientConfig.setReceiveTimeout(100000);
conduit.setClient(clientConfig);
jdbcTemplate.update("delete from EVENTS");
List<EventType> events = new ArrayList<EventType>();
EventType eventType = new EventType();
eventType.setEventType(EventEnumType.REQ_OUT);
URL messageContentFile = this.getClass().getResource("/testmessage.xml").toURI().toURL();
eventType.setContent(new DataHandler(messageContentFile));
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item prop1 = new CustomInfoType.Item();
prop1.setKey("mykey1");
prop1.setValue("myValue1");
ciType.getItem().add(prop1);
CustomInfoType.Item prop2 = new CustomInfoType.Item();
prop2.setKey("mykey2");
prop2.setValue("myValue2");
ciType.getItem().add(prop2);
eventType.setCustomInfo(ciType);
MessageInfoType mit = new MessageInfoType();
mit.setFlowId("uuid");
eventType.setMessageInfo(mit);
events.add(eventType);
String result = monitoringService.putEvents(events);
Assert.assertEquals("success", result);
long id = jdbcTemplate.queryForObject("select id from EVENTS", Long.class);
Event readEvent = eventRepository.readEvent(id);
Assert.assertEquals(EventTypeEnum.REQ_OUT, readEvent.getEventType());
Map<String, String> customInfo = readEvent.getCustomInfo();
Assert.assertEquals("myValue1", customInfo.get("mykey1"));
Assert.assertEquals("myValue2", customInfo.get("mykey2"));
}
Aggregations