use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class JettyDigestAuthTest method setupClient.
private HTTPConduit setupClient(boolean async) throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
BindingProvider bp = (BindingProvider) greeter;
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(greeter).getConduit();
HTTPClientPolicy client = new HTTPClientPolicy();
cond.setClient(client);
if (async) {
if (cond instanceof AsyncHTTPConduit) {
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd");
bp.getRequestContext().put(Credentials.class.getName(), creds);
bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
client.setAutoRedirect(true);
} else {
fail("Not an async conduit");
}
} else {
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
cond.setAuthSupplier(new DigestAuthSupplier());
}
ClientProxy.getClient(greeter).getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.PRE_STREAM_ENDING) {
public void handleMessage(Message message) throws Fault {
Map<String, ?> headers = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
if (headers.containsKey("Proxy-Authorization")) {
throw new RuntimeException("Should not have Proxy-Authorization");
}
}
});
client.setAllowChunking(false);
return cond;
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class JettyBasicAuthTest method setUp.
@Before
public void setUp() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class);
BindingProvider bp = (BindingProvider) greeter;
ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ProviderClientServerTest method testSOAPMessageModeDocLitWithSchemaValidation.
@Test
public void testSOAPMessageModeDocLitWithSchemaValidation() throws Exception {
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
try {
Greeter greeter = service.getPort(portName, Greeter.class);
setAddress(greeter, ADDRESS);
try {
greeter.greetMe("this is a greetMe message which length is more " + "than 30 so that I wanna a schema validation error");
fail("Should have thrown an exception");
} catch (Exception ex) {
// expected
assertTrue(ex.getMessage().contains("the length of the value is 96, but the required maximum is 30"));
}
try {
greeter.greetMe("exceed maxLength");
fail("Should have thrown an exception");
} catch (Exception ex) {
// expected
assertTrue(ex.getMessage().contains("cvc-maxLength-valid"));
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testAsyncSynchronousPolling.
@Test
public void testAsyncSynchronousPolling() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
final String expectedString = new String("Hello, finally!");
class Poller extends Thread {
Response<GreetMeLaterResponse> response;
int tid;
Poller(Response<GreetMeLaterResponse> r, int t) {
response = r;
tid = t;
}
public void run() {
if (tid % 2 > 0) {
while (!response.isDone()) {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
// ignore
}
}
}
GreetMeLaterResponse reply = null;
try {
reply = response.get();
} catch (Exception ex) {
fail("Poller " + tid + " failed with " + ex);
}
assertNotNull("Poller " + tid + ": no response received from service", reply);
String s = reply.getResponseType();
assertEquals(expectedString, s);
}
}
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
long before = System.currentTimeMillis();
long delay = 3000;
Response<GreetMeLaterResponse> response = greeter.greetMeLaterAsync(delay);
long after = System.currentTimeMillis();
assertTrue("Duration of calls exceeded " + delay + " ms", after - before < delay);
// first time round, responses should not be available yet
assertFalse("Response already available.", response.isDone());
Poller[] pollers = new Poller[4];
for (int i = 0; i < pollers.length; i++) {
pollers[i] = new Poller(response, i);
}
for (Poller p : pollers) {
p.start();
}
for (Poller p : pollers) {
p.join();
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testBasicConnectionAndOneway.
@Test
public void testBasicConnectionAndOneway() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
try {
for (int idx = 0; idx < 1; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = response1 + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
greeter.greetMeOneWay("Milestone-" + idx);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
Aggregations