use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class ProviderXMLClientServerTest method testDOMSourcePAYLOAD.
@Test
public void testDOMSourcePAYLOAD() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService(wsdl, serviceName);
assertNotNull(service);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
Document doc = StaxUtils.read(is);
DOMSource reqMsg = new DOMSource(doc);
assertNotNull(reqMsg);
Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Service.Mode.PAYLOAD);
setAddress(disp, ADDRESS);
DOMSource result = disp.invoke(reqMsg);
assertNotNull(result);
Node respDoc = result.getNode();
assertEquals("greetMeResponse", respDoc.getFirstChild().getLocalName());
assertEquals("TestXMLBindingProviderMessage", respDoc.getFirstChild().getTextContent());
is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq_invalid.xml");
doc = StaxUtils.read(is);
reqMsg = new DOMSource(doc);
assertNotNull(reqMsg);
disp = service.createDispatch(portName, DOMSource.class, Service.Mode.PAYLOAD);
try {
setAddress(disp, ADDRESS);
result = disp.invoke(reqMsg);
fail("should have a schema validation exception of some sort");
} catch (Exception ex) {
// expected - different validators are throwing different error messages though
}
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchXMLClientServerTest method testDOMSourcePAYLOAD.
@Test
public void testDOMSourcePAYLOAD() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService(wsdl, SERVICE_NAME);
assertNotNull(service);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
Document doc = StaxUtils.read(is);
DOMSource reqMsg = new DOMSource(doc);
assertNotNull(reqMsg);
Dispatch<DOMSource> disp = service.createDispatch(PORT_NAME, DOMSource.class, Service.Mode.PAYLOAD);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port + "/XMLService/XMLDispatchPort");
DOMSource result = disp.invoke(reqMsg);
assertNotNull(result);
Node respDoc = result.getNode();
assertEquals("greetMeResponse", respDoc.getFirstChild().getLocalName());
assertEquals("Hello tli", respDoc.getFirstChild().getTextContent());
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithJAXBMessageModeXMLBinding.
@Test
public void testInvokeWithJAXBMessageModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_xml_http.wrapped.types");
Dispatch<Object> disp = service.createDispatch(portNameXML, jc, Mode.MESSAGE);
setAddress(disp, greeterAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
org.apache.hello_world_xml_http.wrapped.types.GreetMe req = new org.apache.hello_world_xml_http.wrapped.types.GreetMe();
req.setRequestType("tli");
Object response = disp.invoke(req);
assertNotNull(response);
org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse value = (org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse) response;
assertEquals("Hello tli", value.getResponseType());
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithDataSourcPayloadModeXMLBinding.
@Test
public void testInvokeWithDataSourcPayloadModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DataSource> disp = service.createDispatch(portNameXML, DataSource.class, Mode.PAYLOAD);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
URL is = getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml");
DataSource ds = new URLDataSource(is);
DataSource resp = disp.invoke(ds);
assertNotNull(resp);
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithDOMSourcMessageModeXMLBinding.
@Test
public void testInvokeWithDOMSourcMessageModeXMLBinding() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService();
assertNotNull(service);
Dispatch<DOMSource> disp = service.createDispatch(portNameXML, DOMSource.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandlerXMLBinding handler = new TestHandlerXMLBinding();
addHandlersProgrammatically(disp, handler);
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is);
DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());
DOMSource response = disp.invoke(domReqMessage);
assertNotNull(response);
}
Aggregations