Search in sources :

Example 1 with CECXFClient

use of com.creditease.monitorframework.fat.client.CECXFClient 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)

Aggregations

ConsoleLogger (com.creditease.monitor.log.ConsoleLogger)1 CECXFClient (com.creditease.monitorframework.fat.client.CECXFClient)1 TestService (com.creditease.monitorframework.fat.client.TestService)1 TestService_Service (com.creditease.monitorframework.fat.client.TestService_Service)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1