BusFactory.setDefaultBus(bus);
URL wsdl = this.getClass().getResource("/wsdl_systest_databinding/source/hello_world.wsdl");
assertNotNull("We should have found the WSDL here. " , wsdl);
SOAPService ss = new SOAPService(wsdl, SERVICE_NAME);
Greeter port = ss.getSoapPort();
updateAddressPort(port, WSDL_PORT);
ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor());
ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor());
Document doc = XMLUtils.newDocument();
doc.appendChild(doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:sayHi"));
DOMSource ds = new DOMSource(doc);
DOMSource resp = port.sayHi(ds);
assertEquals("We should get the right response", "Bonjour",
DOMUtils.getContent(getElement(resp.getNode().getFirstChild().getFirstChild())));
doc = XMLUtils.newDocument();
Element el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:greetMe");
Element el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:requestType");
el2.appendChild(doc.createTextNode("Willem"));
el.appendChild(el2);
doc.appendChild(el);
ds = new DOMSource(doc);
resp = port.greetMe(ds);
assertEquals("We should get the right response", "Hello Willem",
DOMUtils.getContent(DOMUtils.getFirstElement(getElement(resp.getNode()))));
try {
doc = XMLUtils.newDocument();
el = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:greetMe");
el2 = doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types",
"ns1:requestType");
el2.appendChild(doc.createTextNode("fault"));
el.appendChild(el2);
doc.appendChild(el);
ds = new DOMSource(doc);
port.greetMe(ds);
fail("Should have been a fault");
} catch (GreetMeFault ex) {
assertEquals("Some fault detail", DOMUtils.getContent(getElement(ex.getFaultInfo().getNode())));
}