use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithJAXBPayloadModeXMLBinding.
@Test
public void testInvokeWithJAXBPayloadModeXMLBinding() 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.PAYLOAD);
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 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(wsdlURL);
XMLService ss = new XMLService(wsdlURL, SERVICE_NAME);
Greeter port = ss.getXMLPort();
String resp;
System.out.println("Invoking sayHi...");
resp = port.sayHi();
System.out.println("Server responded with: " + resp);
System.out.println();
System.out.println("Invoking greetMe...");
resp = port.greetMe(System.getProperty("user.name"));
System.out.println("Server responded with: " + resp);
System.out.println();
System.out.println("Invoking greetMeOneWay...");
port.greetMeOneWay(System.getProperty("user.name"));
System.out.println("No response from server as method is OneWay");
System.out.println();
try {
System.out.println("Invoking pingMe, expecting exception...");
port.pingMe();
} catch (PingMeFault ex) {
System.out.println("Expected exception: " + ex.getMessage());
}
System.exit(0);
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchXMLClientServerTest method testStreamSourceMESSAGE.
@Test
public void testStreamSourceMESSAGE() throws Exception {
/*URL wsdl = getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl");
assertNotNull(wsdl);
XMLService service = new XMLService(wsdl, serviceName);
assertNotNull(service);*/
Service service = Service.create(SERVICE_NAME);
assertNotNull(service);
service.addPort(PORT_NAME, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + port + "/XMLService/XMLDispatchPort");
InputStream is = getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml");
StreamSource reqMsg = new StreamSource(is);
assertNotNull(reqMsg);
Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
Source source = disp.invoke(reqMsg);
assertNotNull(source);
String streamString = StaxUtils.toString(source);
Document doc = StaxUtils.read(new StringReader(streamString));
assertEquals("greetMeResponse", doc.getFirstChild().getLocalName());
assertEquals("Hello tli", doc.getFirstChild().getTextContent());
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchXMLClientServerTest method testJAXBMESSAGE.
@Test
public void testJAXBMESSAGE() throws Exception {
Service service = Service.create(SERVICE_NAME);
assertNotNull(service);
service.addPort(PORT_NAME, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + port + "/XMLService/XMLDispatchPort");
GreetMe gm = new GreetMe();
gm.setRequestType("CXF");
JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class);
Dispatch<Object> disp = service.createDispatch(PORT_NAME, ctx, Service.Mode.MESSAGE);
GreetMeResponse resp = (GreetMeResponse) disp.invoke(gm);
assertNotNull(resp);
assertEquals("Hello CXF", resp.getResponseType());
try {
disp.invoke(null);
fail("Should have thrown a fault");
} catch (WebServiceException ex) {
// expected
}
}
use of org.apache.hello_world_xml_http.wrapped.XMLService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithDataSourcMessageModeXMLBinding.
@Test
public void testInvokeWithDataSourcMessageModeXMLBinding() 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.MESSAGE);
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);
}
Aggregations