use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class DispatchClientServerWithHugeResponseTest method testStackOverflowErrorForSOAPMessageWithHugeResponse.
@Test
public void testStackOverflowErrorForSOAPMessageWithHugeResponse() throws Exception {
HugeResponseInterceptor hugeResponseInterceptor = new HugeResponseInterceptor(ResponseInterceptorType.overflow);
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) {
assertTrue(e.getCause() instanceof StackOverflowError);
} 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");
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);
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 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 innerElementCountThreshold") || msg.contains("Maximum Number of Child Elements"));
} finally {
getBus().getInInterceptors().remove(hugeResponseInterceptor);
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class Client method main.
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("WSDL : " + wsdlURL);
SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
Greeter port = ss.getPort(PORT_NAME, Greeter.class);
System.out.println("Invoking greetMe...");
try {
String resp = port.greetMe(System.getProperty("user.name"));
System.out.println("Server responded with: " + resp);
System.out.println();
} catch (Exception e) {
System.out.println("Invocation failed with the following: " + e.getCause());
System.out.println();
}
System.exit(0);
}
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);
}
Aggregations