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