Search in sources :

Example 16 with JaxWsDynamicClientFactory

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

the class CXFWebServiceWorkItemHandler method executeWorkItem.

public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    long workItemId = workItem.getId();
    Map<String, Object> input = workItem.getParameters();
    String wsdlUrl = (String) input.get("wsdlUrl");
    String methodName = (String) input.get("methodName");
    String argumentNamesString = (String) input.get("webServiceParameters");
    String outputName = (String) input.get("outputName");
    String[] argumentNames = argumentNamesString.split(",");
    Object[] arguments = new Object[argumentNames.length];
    for (int index = 0; index < argumentNames.length; index++) {
        Object argument = input.get(argumentNames[index]);
        arguments[index] = argument;
    }
    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
    Client client = dcf.createClient(wsdlUrl);
    try {
        Object[] result = client.invoke(methodName, arguments);
        Map<String, Object> output = new HashMap<String, Object>();
        if (result == null) {
            System.out.println("Null response");
            output.put(outputName, null);
        } else {
            System.out.println("Echo response: " + result[0]);
            output.put(outputName, result[0]);
        }
        manager.completeWorkItem(workItemId, output);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) HashMap(java.util.HashMap) 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