Search in sources :

Example 6 with HTTPConduit

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client)

Example 7 with HTTPConduit

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) AnyServerX509TrustManager(org.opennms.core.utils.AnyServerX509TrustManager) IOException(java.io.IOException) Client(org.apache.cxf.endpoint.Client) SHSIMPINC(com.ibm.maximo.wsdl.shsimpinc.SHSIMPINC) AnyServerX509TrustManager(org.opennms.core.utils.AnyServerX509TrustManager) TrustManager(javax.net.ssl.TrustManager)

Example 8 with HTTPConduit

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();
    }
}
Also used : HashMap(java.util.HashMap) TestService_Service(com.creditease.monitorframework.fat.client.TestService_Service) TestService(com.creditease.monitorframework.fat.client.TestService) QName(javax.xml.namespace.QName) SOAPMessage(javax.xml.soap.SOAPMessage) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ConsoleLogger(com.creditease.monitor.log.ConsoleLogger) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) CECXFClient(com.creditease.monitorframework.fat.client.CECXFClient) Client(org.apache.cxf.endpoint.Client) CECXFClient(com.creditease.monitorframework.fat.client.CECXFClient) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with HTTPConduit

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit)

Example 10 with HTTPConduit

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"));
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) ArrayList(java.util.ArrayList) DataHandler(javax.activation.DataHandler) URL(java.net.URL) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Event(org.talend.esb.sam.common.event.Event) Client(org.apache.cxf.endpoint.Client) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Aggregations

HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)158 Client (org.apache.cxf.endpoint.Client)65 Test (org.junit.Test)60 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)52 URL (java.net.URL)43 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)43 Bus (org.apache.cxf.Bus)36 QName (javax.xml.namespace.QName)24 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)23 KeyStore (java.security.KeyStore)21 Greeter (org.apache.hello_world.Greeter)21 SOAPService (org.apache.hello_world.services.SOAPService)21 Service (javax.xml.ws.Service)18 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)17 InputStream (java.io.InputStream)15 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)15 IOException (java.io.IOException)13 ExecutionException (java.util.concurrent.ExecutionException)13 TrustManager (javax.net.ssl.TrustManager)13 WebClient (org.apache.cxf.jaxrs.client.WebClient)11