use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerTest method testAsyncCallWithHandlerAndMultipleClients.
@Test
public void testAsyncCallWithHandlerAndMultipleClients() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
final MyHandler h = new MyHandler();
MyHandler.invocationCount = 0;
final String expectedString = new String("Hello, finally!");
class Poller extends Thread {
Future<?> future;
int tid;
Poller(Future<?> f, int t) {
future = f;
tid = t;
}
public void run() {
if (tid % 2 > 0) {
while (!future.isDone()) {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
// ignore
ex.printStackTrace();
}
}
}
try {
future.get();
} catch (Exception ex) {
fail("Poller " + tid + " failed with " + ex);
}
assertEquals("callback was not executed or did not return the expected result", expectedString, h.getReplyBuffer());
}
}
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
long before = System.currentTimeMillis();
long delay = 3000;
Future<?> f = greeter.greetMeLaterAsync(delay, h);
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.", f.isDone());
Poller[] pollers = new Poller[4];
for (int i = 0; i < pollers.length; i++) {
pollers[i] = new Poller(f, i);
}
for (Poller p : pollers) {
p.start();
}
for (Poller p : pollers) {
p.join();
}
assertEquals(1, MyHandler.invocationCount);
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class BusShutdownTest method doWork.
private void doWork(URL wsdlUrl, String address) {
SOAPService service = new SOAPService(wsdlUrl);
assertNotNull(service);
Greeter greeter = service.getSoapPort();
// overwrite client address
InvocationHandler handler = Proxy.getInvocationHandler(greeter);
BindingProvider bp = (BindingProvider) handler;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
Client client = ClientProxy.getClient(greeter);
HTTPConduit c = (HTTPConduit) client.getConduit();
c.setClient(new HTTPClientPolicy());
c.getClient().setConnection(ConnectionType.CLOSE);
// invoke twoway call
greeter.sayHi();
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class SSLNettyServerTest method start.
@BeforeClass
public static void start() throws Exception {
Bus b = createStaticBus("/org/apache/cxf/transport/http/netty/server/integration/ServerConfig.xml");
// setup the ssl interceptor
MySSLInterceptor myInterceptor = new MySSLInterceptor();
b.getInInterceptors().add(myInterceptor);
BusFactory.setThreadDefaultBus(b);
address = "https://localhost:" + PORT + "/SoapContext/SoapPort";
ep = Endpoint.publish(address, new org.apache.hello_world_soap_http.GreeterImpl());
URL wsdl = NettyServerTest.class.getResource("/wsdl/hello_world.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl);
assertNotNull("Service is null", service);
g = service.getSoapPort();
assertNotNull("Port is null", g);
}
use of org.apache.hello_world_soap_http.SOAPService in project camel by apache.
the class CxfSoapMessageProviderTest method testSOAPMessageModeDocLit.
@Test
public void testSOAPMessageModeDocLit() throws Exception {
JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
fromHandler.reset();
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);
String response1 = new String("TestSOAPOutputPMessage");
String response2 = new String("Bonjour");
try {
Greeter greeter = service.getPort(portName, Greeter.class);
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port + "/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
for (int idx = 0; idx < 2; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
assertEquals(response1, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
assertEquals("Can't get the right message count", fromHandler.getMessageCount(), 8);
assertEquals("Can't get the right fault count", fromHandler.getFaultCount(), 0);
//From CXF 2.2.7 the soap handler's getHeader() method will not be called if the SOAP message don't have headers
//assertEquals("Can't get the right headers count", fromHandler.getGetHeadersCount(), 4);
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class DispatchClientServerWithHugeResponseTest method testThresholdfForSOAPMessageWithHugeResponse.
@Test
public void testThresholdfForSOAPMessageWithHugeResponse() throws Exception {
HugeResponseInterceptor hugeResponseInterceptor = new HugeResponseInterceptor(ResponseInterceptorType.ElementLevelThreshold);
getBus().getInInterceptors().add(hugeResponseInterceptor);
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
assertNotNull(service);
Dispatch<SOAPMessage> disp = service.createDispatch(PORT_NAME, SOAPMessage.class, Service.Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
StaxUtils.setInnerElementCountThreshold(12);
StaxUtils.setInnerElementLevelThreshold(12);
InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
assertNotNull(soapReqMsg3);
Response<SOAPMessage> response = disp.invokeAsync(soapReqMsg3);
try {
response.get(300, TimeUnit.SECONDS);
} catch (TimeoutException te) {
fail("We should not have encountered a timeout, " + "should get some exception tell me stackoverflow");
} catch (Throwable e) {
if (e.getCause() == null) {
throw e;
}
Throwable t = e.getCause();
if (t instanceof SoapFault) {
SoapFault sf = (SoapFault) e.getCause();
if (sf.getCause() == null) {
throw e;
}
t = sf.getCause();
}
if (t.getMessage() == null) {
throw e;
}
String msg = t.getMessage();
assertTrue(msg, msg.startsWith("reach the innerElementLevelThreshold") || msg.contains("Maximum Element Depth limit"));
} finally {
getBus().getInInterceptors().remove(hugeResponseInterceptor);
}
}
Aggregations