use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project uavstack by uavorg.
the class CXFClientE2ETest method doGet.
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest request,
* javax.servlet.http.HttpServletResponse response)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String test = request.getParameter("test");
if (test == null || "good".equals(test)) {
TestService_Service service = new TestService_Service();
TestService ts = service.getPort(TestService.class);
ts.echo();
} else if ("fault".equals(test)) {
TestService_Service service = new TestService_Service();
TestService ts = service.getPort(TestService.class);
ts.echoFault();
} else if ("async1".equals(test)) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(TestService_Service.WSDL_LOCATION);
try {
client.invokeWrapped(new ClientCallback() {
@Override
public void handleResponse(Map<String, Object> ctx, Object[] res) {
super.handleResponse(ctx, res);
}
@Override
public void handleException(Map<String, Object> ctx, Throwable ex) {
super.handleException(ctx, ex);
}
}, "echo");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if ("async0".equals(test)) {
Service sr = Service.create(TestService_Service.WSDL_LOCATION, TestService_Service.SERVICE);
JAXBContext jc = null;
try {
jc = JAXBContext.newInstance("com.creditease.monitorframework.fat.client");
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Dispatch d = sr.createDispatch(TestService_Service.TestServicePort, jc, Mode.PAYLOAD);
d.invokeAsync(null, new AsyncHandler() {
@Override
public void handleResponse(Response res) {
if (res.isDone()) {
try {
System.out.println(res.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
});
}
}
use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.
the class ComplexClient method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("please specify wsdl");
System.exit(1);
}
URL wsdlURL;
File wsdlFile = new File(args[0]);
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
System.out.println(wsdlURL);
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
ClientImpl clientImpl = (ClientImpl) client;
Endpoint endpoint = clientImpl.getEndpoint();
ServiceInfo serviceInfo = endpoint.getService().getServiceInfos().get(0);
QName bindingName = new QName("http://Company.com/Application", "Company_ESB_Application_Biztalk_AgentDetails_4405_AgentDetails_PrtSoap");
BindingInfo binding = serviceInfo.getBinding(bindingName);
// {
QName opName = new QName("http://Company.com/Application", "GetAgentDetails");
BindingOperationInfo boi = binding.getOperation(opName);
BindingMessageInfo inputMessageInfo = boi.getInput();
List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();
// only one part.
MessagePartInfo partInfo = parts.get(0);
Class<?> partClass = partInfo.getTypeClass();
// GetAgentDetails
System.out.println(partClass.getCanonicalName());
Object inputObject = partClass.newInstance();
// Unfortunately, the slot inside of the part object is also called 'part'.
// this is the descriptor for get/set part inside the GetAgentDetails class.
PropertyDescriptor partPropertyDescriptor = new PropertyDescriptor("part", partClass);
// This is the type of the class which really contains all the parameter information.
// AgentWSRequest
Class<?> partPropType = partPropertyDescriptor.getPropertyType();
System.out.println(partPropType.getCanonicalName());
Object inputPartObject = partPropType.newInstance();
partPropertyDescriptor.getWriteMethod().invoke(inputObject, inputPartObject);
PropertyDescriptor numberPropertyDescriptor = new PropertyDescriptor("agentNumber", partPropType);
numberPropertyDescriptor.getWriteMethod().invoke(inputPartObject, new Integer(314159));
Object[] result = client.invoke(opName, inputObject);
Class<?> resultClass = result[0].getClass();
// GetAgentDetailsResponse
System.out.println(resultClass.getCanonicalName());
PropertyDescriptor resultDescriptor = new PropertyDescriptor("agentWSResponse", resultClass);
Object wsResponse = resultDescriptor.getReadMethod().invoke(result[0]);
Class<?> wsResponseClass = wsResponse.getClass();
System.out.println(wsResponseClass.getCanonicalName());
PropertyDescriptor agentNameDescriptor = new PropertyDescriptor("agentName", wsResponseClass);
String agentName = (String) agentNameDescriptor.getReadMethod().invoke(wsResponse);
System.out.println("Agent name: " + agentName);
}
use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.
the class JaxWsDynamicClientTest method testArgfiles.
@Test
public void testArgfiles() throws Exception {
System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true");
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
String[] values = new String[] { "foobar", "something" };
List<String> list = Arrays.asList(values);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.invoke("init", list);
}
use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.
the class JaxWsDynamicClientTest method testArrayList.
@Test
public void testArrayList() throws Exception {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
String[] values = new String[] { "foobar", "something" };
List<String> list = Arrays.asList(values);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.invoke("init", list);
}
use of org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory in project cxf by apache.
the class JettyBasicAuthTest 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");
}
Aggregations