use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.
the class DispatchTest method testFindOperationWithSource.
@Test
public void testFindOperationWithSource() throws Exception {
ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), serviceName, null);
Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
disp.getRequestContext().put("find.dispatch.operation", Boolean.TRUE);
d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
BindingOperationVerifier bov = new BindingOperationVerifier();
((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
Document doc = StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
DOMSource source = new DOMSource(doc);
Source res = disp.invoke(source);
assertNotNull(res);
BindingOperationInfo boi = bov.getBindingOperationInfo();
assertNotNull(boi);
assertEquals(new QName("http://apache.org/hello_world_soap_http", "sayHi"), boi.getName());
}
use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.
the class SymmetricBindingTest method testUsernameTokenSAML1Dispatch.
@org.junit.Test
public void testUsernameTokenSAML1Dispatch() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1Port");
Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
updateAddressPort(dispatch, test.getPort());
// Setup STSClient
STSClient stsClient = createDispatchSTSClient(bus);
String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
stsClient.setWsdlLocation(wsdlLocation);
// Creating a DOMSource Object for the request
DOMSource request = createDOMRequest();
// Make a successful request
Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
if (test.isStreaming()) {
client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
}
DOMSource response = dispatch.invoke(request);
assertNotNull(response);
bus.shutdown(true);
}
use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.
the class TransportBindingTest method testSAML2DispatchLocation.
@org.junit.Test
public void testSAML2DispatchLocation() throws Exception {
// Needed to prevent test failure using IBM JDK
if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
System.setProperty("https.protocols", "TLSv1");
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = TransportBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = TransportBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
updateAddressPort(dispatch, test.getPort());
// Setup STSClient
STSClient stsClient = createDispatchSTSClient(bus);
String location = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport";
stsClient.setLocation(location);
stsClient.setPolicy("classpath:/org/apache/cxf/systest/sts/issuer/sts-transport-policy.xml");
// Creating a DOMSource Object for the request
DOMSource request = createDOMRequest();
// Make a successful request
Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
client.getRequestContext().put(SecurityConstants.USERNAME, "alice");
client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
if (test.isStreaming()) {
client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
}
DOMSource response = dispatch.invoke(request);
assertNotNull(response);
bus.shutdown(true);
}
use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.
the class TransportBindingTest method testSAML2Dispatch.
@org.junit.Test
public void testSAML2Dispatch() throws Exception {
// Needed to prevent test failure using IBM JDK
if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
System.setProperty("https.protocols", "TLSv1");
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = TransportBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = TransportBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
updateAddressPort(dispatch, test.getPort());
// Setup STSClient
STSClient stsClient = createDispatchSTSClient(bus);
String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
stsClient.setWsdlLocation(wsdlLocation);
// Creating a DOMSource Object for the request
DOMSource request = createDOMRequest();
// Make a successful request
Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
client.getRequestContext().put(SecurityConstants.USERNAME, "alice");
client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
if (test.isStreaming()) {
client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
}
DOMSource response = dispatch.invoke(request);
assertNotNull(response);
bus.shutdown(true);
}
use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.
the class ClientServerTest method testEchoProviderAsyncDecoupledEndpoints.
@Test
public void testEchoProviderAsyncDecoupledEndpoints() throws Exception {
String requestString = "<echo/>";
Service service = Service.create(serviceName);
service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider");
Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName, StreamSource.class, Service.Mode.PAYLOAD);
Client client = ((DispatchImpl<StreamSource>) dispatcher).getClient();
WSAddressingFeature wsAddressingFeature = new WSAddressingFeature();
wsAddressingFeature.initialize(client, client.getBus());
dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto", "http://localhost:" + CLIENT_PORT + "/SoapContext/AsyncEchoClient");
StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes()));
StreamSource response = dispatcher.invoke(request);
assertEquals(requestString, StaxUtils.toString(response));
}
Aggregations