use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class DispatchTest method testSOAPPBindingNullMessage.
@Test
public void testSOAPPBindingNullMessage() throws Exception {
d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
try {
// Send a null message
disp.invoke(null);
} catch (SOAPFaultException e) {
// Passed
return;
}
fail("SOAPFaultException was not thrown");
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class DispatchTest method testJAXB.
@Test
public void testJAXB() throws Exception {
d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
SayHi s = new SayHi();
Object response = disp.invoke(s);
assertNotNull(response);
assertTrue(response instanceof SayHiResponse);
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class AsyncHTTPConduitTest method start.
@BeforeClass
public static void start() throws Exception {
Bus b = createStaticBus();
b.setProperty(AsyncHTTPConduit.USE_ASYNC, AsyncHTTPConduitFactory.UseAsyncPolicy.ALWAYS);
b.setProperty("org.apache.cxf.transport.http.async.MAX_CONNECTIONS", 501);
BusFactory.setThreadDefaultBus(b);
AsyncHTTPConduitFactory hcf = (AsyncHTTPConduitFactory) b.getExtension(HTTPConduitFactory.class);
assertEquals(501, hcf.maxConnections);
ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort", new org.apache.hello_world_soap_http.GreeterImpl() {
public String greetMeLater(long cnt) {
// use the continuations so the async client can
// have a ton of connections, use less threads
//
// mimic a slow server by delaying somewhere between
// 1 and 2 seconds, with a preference of delaying the earlier
// requests longer to create a sort of backlog/contention
// with the later requests
ContinuationProvider p = (ContinuationProvider) getContext().getMessageContext().get(ContinuationProvider.class.getName());
Continuation c = p.getContinuation();
if (c.isNew()) {
if (cnt < 0) {
c.suspend(-cnt);
} else {
c.suspend(2000 - (cnt % 1000));
}
return null;
}
return "Hello, finally! " + cnt;
}
public String greetMe(String me) {
if (me.equals(FILL_BUFFER)) {
return String.join("", Collections.nCopies(16093, " "));
} else {
return "Hello " + me;
}
}
});
StringBuilder builder = new StringBuilder("NaNaNa");
for (int x = 0; x < 50; x++) {
builder.append(" NaNaNa ");
}
request = builder.toString();
URL wsdl = AsyncHTTPConduitTest.class.getResource("/wsdl/hello_world_services.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService();
assertNotNull("Service is null", service);
g = service.getSoapPort();
assertNotNull("Port is null", g);
}
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");
InputStream is3 = getClass().getResourceAsStream("GreetMeDocLiteralReq3.xml");
SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
assertNotNull(soapReqMsg3);
Response<SOAPMessage> response = disp.invokeAsync(soapReqMsg3);
try {
response.get(300, TimeUnit.SECONDS);
fail("should catch exception");
} 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 SOAPFaultException) {
SoapFault sf = (SoapFault) t.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);
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class DispatchClientServerWithHugeResponseTest method testElementCountThresholdfForSOAPMessageWithHugeResponse.
@Test
public void testElementCountThresholdfForSOAPMessageWithHugeResponse() throws Throwable {
HugeResponseInterceptor hugeResponseInterceptor = new HugeResponseInterceptor(ResponseInterceptorType.ElementCountThreshold);
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");
InputStream is3 = getClass().getResourceAsStream("GreetMeDocLiteralReq3.xml");
SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
assertNotNull(soapReqMsg3);
Response<SOAPMessage> response = disp.invokeAsync(soapReqMsg3);
try {
response.get(300, TimeUnit.SECONDS);
fail("should catch exception");
} catch (TimeoutException te) {
fail("We should not have encountered a timeout, " + "should get some exception tell me stackoverflow");
} catch (ExecutionException e) {
if (e.getCause() == null) {
throw e;
}
Throwable t = e.getCause();
if (t instanceof SOAPFaultException) {
SoapFault sf = (SoapFault) t.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 innerElementCountThreshold") || msg.contains("Maximum Number of Child Elements"));
} finally {
getBus().getInInterceptors().remove(hugeResponseInterceptor);
}
}
Aggregations