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);
}
}
Aggregations