Search in sources :

Example 6 with JaxWsDynamicClientFactory

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

the class JettyDigestAuthTest 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) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Test(org.junit.Test)

Example 7 with JaxWsDynamicClientFactory

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

the class CULegacyTravelServiceImpl method getLegacyTripID.

/**
 * @param docID the KFS e-doc id that will be used to try and find an associated trip in the DFA Travel application
 * @return If a corresponding trip can be found in the DFA travel application, the Trip ID will be returned, if no corresponding trip can be found, an empty string is returned.
 *
 * NOTE : If the call fails to successfully retrieve a value or a blank string from the DFA Travel application, a null value is returned to indicate the call failed.
 */
// @Cached
public String getLegacyTripID(String docID) {
    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);
        // client = dcf.createClient(wsdlUrl);
        configureWebServiceClient(client);
        Object[] results1 = client.invoke(DFA_TRAVEL_WS_METHODS.GET_TRIP_ID, docID);
        String tripID = (String) results1[0];
        return tripID;
    } catch (SoapFault sf) {
        LOG.error(sf.getMessage());
        sf.printStackTrace();
        // Returning null is used as an indicator that the call might have failed
        return null;
    } catch (Exception ex) {
        LOG.error("Exception occurred while trying to retrieve Trip ID.", ex);
        ex.printStackTrace();
        // Returning null is used as an indicator that the call might have failed
        return null;
    } 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 8 with JaxWsDynamicClientFactory

use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project jBPM5-Developer-Guide by Salaboy.

the class CXFWebServiceCommand method execute.

public ExecutionResults execute(CommandContext ctx) {
    String wsdlUrl = (String) ctx.getData("wsdlUrl");
    String methodName = (String) ctx.getData("methodName");
    String argumentNamesString = (String) ctx.getData("webServiceParameters");
    String outputName = (String) ctx.getData("outputName");
    String[] argumentNames = argumentNamesString.split(",");
    Object[] arguments = new Object[argumentNames.length];
    for (int index = 0; index < argumentNames.length; index++) {
        Object argument = ctx.getData(argumentNames[index]);
        arguments[index] = argument;
    }
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient(wsdlUrl, CXFWebServiceCommand.class.getClassLoader());
    ExecutionResults results = new ExecutionResults();
    try {
        Object[] result = client.invoke(methodName, arguments);
        if (result == null) {
            System.out.println("Null response");
            results.setData(outputName, null);
        } else {
            System.out.println("Echo response: " + result[0]);
            results.setData(outputName, (Serializable) result[0]);
        }
    } catch (Exception e) {
        results.setData(outputName, e);
        System.out.println("Exception inside CXFCmd: " + e.getMessage());
        e.printStackTrace(System.out);
    }
    return results;
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) ExecutionResults(org.jbpm.executor.api.ExecutionResults) Client(org.apache.cxf.endpoint.Client)

Example 9 with JaxWsDynamicClientFactory

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

the class CXF5061Test method testCxf5061.

@Test
public void testCxf5061() throws Exception {
    if (System.getProperty("java.version").startsWith("9")) {
        System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
    }
    // using dcf to generate client from the wsdl which ensure the wsdl is valid
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    dcf.createClient(ADDRESS + "?wsdl");
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) Test(org.junit.Test)

Example 10 with JaxWsDynamicClientFactory

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

the class ClientServerMiscTest method testDynamicClientExceptions.

@Test
public void testDynamicClientExceptions() throws Exception {
    if (System.getProperty("java.version").startsWith("9")) {
        System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
    }
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    URL wsdlURL = new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl");
    Client client = dcf.createClient(wsdlURL);
    try {
        client.invoke("throwException", -2);
    } catch (Exception ex) {
        Object o = ex.getClass().getMethod("getFaultInfo").invoke(ex);
        assertNotNull(o);
    }
    try {
        client.getRequestContext().put("disable-fault-mapping", true);
        client.invoke("throwException", -2);
    } catch (SoapFault ex) {
    // expected
    }
}
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) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) WebServiceException(javax.xml.ws.WebServiceException) JaxbElementTest(org.apache.cxf.jaxb_element_test.JaxbElementTest) Test(org.junit.Test)

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