SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
assertNotNull(service);
InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
InputSource inputSource = new InputSource(is);
SAXSource saxSourceReq = new SAXSource(inputSource);
assertNotNull(saxSourceReq);
Dispatch<SAXSource> disp = service.createDispatch(PORT_NAME, SAXSource.class, Service.Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ greeterPort
+ "/SOAPDispatchService/SoapDispatchPort");
SAXSource saxSourceResp = disp.invoke(saxSourceReq);
assertNotNull(saxSourceResp);
String expected = "Hello TestSOAPInputMessage";
assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp).contains(expected));
// Test oneway
InputStream is1 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq1.xml");
InputSource inputSource1 = new InputSource(is1);
SAXSource saxSourceReq1 = new SAXSource(inputSource1);
assertNotNull(saxSourceReq1);
disp.invokeOneWay(saxSourceReq1);
// Test async polling
InputStream is2 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq2.xml");
InputSource inputSource2 = new InputSource(is2);
SAXSource saxSourceReq2 = new SAXSource(inputSource2);
assertNotNull(saxSourceReq2);
Response<SAXSource> response = disp.invokeAsync(saxSourceReq2);
SAXSource saxSourceResp2 = response.get();
assertNotNull(saxSourceResp2);
String expected2 = "Hello TestSOAPInputMessage2";
assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp2).contains(expected2));
// Test async callback
InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
InputSource inputSource3 = new InputSource(is3);
SAXSource saxSourceReq3 = new SAXSource(inputSource3);
assertNotNull(saxSourceReq3);
TestSAXSourceHandler tssh = new TestSAXSourceHandler();
Future<?> fd = disp.invokeAsync(saxSourceReq3, tssh);
assertNotNull(fd);
waitForFuture(fd);
String expected3 = "Hello TestSOAPInputMessage3";
SAXSource saxSourceResp3 = tssh.getSAXSource();
assertNotNull(saxSourceResp3);
assertTrue("Expected: " + expected, XMLUtils.toString(saxSourceResp3).contains(expected3));
}