Search in sources :

Example 11 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.

the class UndertowBasicAuthTest method testGetWSDL.

@org.junit.Test
public void testGetWSDL() throws Exception {
    BusFactory bf = BusFactory.newInstance();
    Bus bus = bf.createBus();
    bus.getInInterceptors().add(new LoggingInInterceptor());
    bus.getOutInterceptors().add(new LoggingOutInterceptor());
    MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer();
    bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class);
    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus);
    factory.createClient(ADDRESS + "?wsdl");
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) Bus(org.apache.cxf.Bus) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BusFactory(org.apache.cxf.BusFactory)

Example 12 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.

the class UndertowDigestAuthTest method testGetWSDL.

@Test
public void testGetWSDL() throws Exception {
    BusFactory bf = BusFactory.newInstance();
    Bus bus = bf.createBus();
    bus.getInInterceptors().add(new LoggingInInterceptor());
    bus.getOutInterceptors().add(new LoggingOutInterceptor());
    MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer();
    bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class);
    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus);
    factory.createClient(ADDRESS + "?wsdl");
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) Bus(org.apache.cxf.Bus) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BusFactory(org.apache.cxf.BusFactory) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Test(org.junit.Test)

Example 13 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.

the class JaxWsDynamicClientTest method testInvocation.

@Test
public void testInvocation() throws Exception {
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    URL wsdlURL = new URL("http://localhost:" + PORT + "/NoBodyParts/NoBodyPartsService?wsdl");
    Client client = dcf.createClient(wsdlURL);
    byte[] bucketOfBytes = IOUtils.readBytesFromStream(getClass().getResourceAsStream("/wsdl/no_body_parts.wsdl"));
    Operation1 parameters = new Operation1();
    parameters.setOptionString("opt-ion");
    parameters.setTargetType("tar-get");
    Object[] rparts = client.invoke("operation1", parameters, bucketOfBytes);
    Operation1Response r = (Operation1Response) rparts[0];
    assertEquals(md5(bucketOfBytes), r.getStatus());
    ClientCallback callback = new ClientCallback();
    client.invoke(callback, "operation1", parameters, bucketOfBytes);
    rparts = callback.get();
    r = (Operation1Response) rparts[0];
    assertEquals(md5(bucketOfBytes), r.getStatus());
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) ClientCallback(org.apache.cxf.endpoint.ClientCallback) Operation1Response(org.apache.cxf.no_body_parts.types.Operation1Response) Operation1(org.apache.cxf.no_body_parts.types.Operation1) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) Test(org.junit.Test)

Example 14 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cu-kfs by CU-CommunityApps.

the class CULegacyTravelServiceImpl method reopenLegacyTrip.

/**
 * @param dvID
 * @param disapproveReason
 * @return
 */
public boolean reopenLegacyTrip(String docID, String disapproveReason) {
    Client client = null;
    // Need to grab copy of current class loader because call to web services wrecks class loader, so we want to restore it following call.
    ClassLoader classLoader = ClassLoaderUtils.getDefaultClassLoader();
    try {
        URL wsdlUrl = new URL(updateTripWsdl);
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        client = dcf.createClient(wsdlUrl);
        configureWebServiceClient(client);
        // Method signature on Travel side:  updateTrip(String status, String updaterNetID, String dvID, String voidReason)
        Object[] results1 = client.invoke(DFA_TRAVEL_WS_METHODS.UPDATE_TRIP, KFS_DOC_VOIDED, GlobalVariables.getUserSession().getPrincipalName(), docID, disapproveReason);
        Boolean tripReopened = (Boolean) results1[0];
        return tripReopened;
    } catch (SoapFault sf) {
        LOG.error(sf.getMessage());
        sf.printStackTrace();
        return false;
    } catch (Exception ex) {
        LOG.info("Exception occurred while trying to cancel a trip.");
        ex.printStackTrace();
        return false;
    } finally {
        if (client != null) {
            client.destroy();
        }
        // Restore class loader that was grabbed before call to web service
        ContextClassLoaderBinder.bind(classLoader);
    }
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) SoapFault(org.apache.cxf.binding.soap.SoapFault) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Example 15 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project springBoot-learn-demo by nbfujx.

the class CxfClient method echo.

public static void echo() {
    // 创建动态客户端
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient("http://localhost:8080/services/ExampleService?wsdl");
    Object[] objects = new Object[0];
    try {
        objects = client.invoke("echo", "str");
        System.out.println("echo:" + objects[0]);
    } catch (java.lang.Exception e) {
        e.printStackTrace();
    }
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) Client(org.apache.cxf.endpoint.Client)

Aggregations

JaxWsDynamicClientFactory (org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory)16 Client (org.apache.cxf.endpoint.Client)11 URL (java.net.URL)7 Test (org.junit.Test)7 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)6 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)6 Bus (org.apache.cxf.Bus)4 BusFactory (org.apache.cxf.BusFactory)4 SoapFault (org.apache.cxf.binding.soap.SoapFault)3 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 ClientCallback (org.apache.cxf.endpoint.ClientCallback)2 TestService (com.creditease.monitorframework.fat.client.TestService)1 TestService_Service (com.creditease.monitorframework.fat.client.TestService_Service)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 File (java.io.File)1 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 ServletException (javax.servlet.ServletException)1