use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.
the class JaxWsClientTest method testEndpoint.
@Test
public void testEndpoint() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
bean.setWsdlURL(resource.toString());
bean.setBus(getBus());
bean.setServiceClass(GreeterImpl.class);
GreeterImpl greeter = new GreeterImpl();
BeanInvoker invoker = new BeanInvoker(greeter);
bean.setInvoker(invoker);
Service service = bean.create();
String namespace = "http://apache.org/hello_world_soap_http";
EndpointInfo ei = service.getServiceInfos().get(0).getEndpoint(new QName(namespace, "SoapPort"));
JaxWsEndpointImpl endpoint = new JaxWsEndpointImpl(getBus(), service, ei);
ClientImpl client = new ClientImpl(getBus(), endpoint);
BindingOperationInfo bop = ei.getBinding().getOperation(new QName(namespace, "sayHi"));
assertNotNull(bop);
bop = bop.getUnwrappedOperation();
assertNotNull(bop);
MessagePartInfo part = bop.getOutput().getMessageParts().get(0);
assertEquals(0, part.getIndex());
d.setMessageObserver(new MessageReplayObserver("sayHiResponse.xml"));
Object[] ret = client.invoke(bop, new Object[] { "hi" }, null);
assertNotNull(ret);
assertEquals("Wrong number of return objects", 1, ret.length);
// test fault handling
bop = ei.getBinding().getOperation(new QName(namespace, "testDocLitFault"));
bop = bop.getUnwrappedOperation();
d.setMessageObserver(new MessageReplayObserver("testDocLitFault.xml"));
try {
client.invoke(bop, new Object[] { "BadRecordLitFault" }, null);
fail("Should have returned a fault!");
} catch (BadRecordLitFault fault) {
assertEquals("foo", fault.getFaultInfo().trim());
assertEquals("Hadrian did it.", fault.getMessage());
}
try {
client.getEndpoint().getOutInterceptors().add(new NestedFaultThrower());
client.getEndpoint().getOutInterceptors().add(new FaultThrower());
client.invoke(bop, new Object[] { "BadRecordLitFault" }, null);
fail("Should have returned a fault!");
} catch (Fault fault) {
assertEquals(true, fault.getMessage().indexOf("Foo") >= 0);
}
client.close();
}
use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testEndpoint.
@Test
public void testEndpoint() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
bean.setWsdlURL(resource.toString());
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(GreeterImpl.class);
BeanInvoker invoker = new BeanInvoker(new GreeterImpl());
bean.setInvoker(invoker);
Service service = bean.create();
String ns = "http://apache.org/hello_world_soap_http";
assertEquals("SOAPService", service.getName().getLocalPart());
assertEquals(ns, service.getName().getNamespaceURI());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
OperationInfo op = intf.getOperation(new QName(ns, "sayHi"));
Class<?> wrapper = op.getInput().getMessageParts().get(0).getTypeClass();
assertNotNull(wrapper);
wrapper = op.getOutput().getMessageParts().get(0).getTypeClass();
assertNotNull(wrapper);
assertEquals(invoker, service.getInvoker());
op = intf.getOperation(new QName(ns, "testDocLitFault"));
Collection<FaultInfo> faults = op.getFaults();
assertEquals(2, faults.size());
FaultInfo f = op.getFault(new QName(ns, "BadRecordLitFault"));
assertNotNull(f);
Class<?> c = f.getProperty(Class.class.getName(), Class.class);
assertNotNull(c);
assertEquals(1, f.getMessageParts().size());
MessagePartInfo mpi = f.getMessagePartByIndex(0);
assertNotNull(mpi.getTypeClass());
}
use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.
the class MissingTypeWSDLTest method testMissingTransliteration.
@Test
public void testMissingTransliteration() throws Exception {
Server server = createService(MissingType.class, new MissingTypeImpl(), null);
Service service = server.getEndpoint().getService();
service.setInvoker(new BeanInvoker(new MissingTypeImpl()));
ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
proxyFac.setAddress("local://MissingType");
proxyFac.setBus(getBus());
setupAegis(proxyFac.getClientFactoryBean());
Document wsdl = getWSDLDocument("MissingType");
assertValid("/wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='urn:org:apache:cxf:aegis:type:missing']" + "/xsd:complexType[@name=\"Inner\"]", wsdl);
}
use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.
the class ProxyTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
Server s = createService(HelloProxyService.class, new HelloProxyServiceImpl(), null);
s.getEndpoint().getService().setInvoker(new BeanInvoker(new HelloProxyServiceImpl()));
}
use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.
the class ExceptionTest method testJaxwsNoXfireCompat.
@Test(expected = HelloException.class)
public void testJaxwsNoXfireCompat() throws Exception {
JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
sfbean.setServiceClass(ExceptionService.class);
sfbean.setDataBinding(new AegisDatabinding());
sfbean.getServiceFactory().setDataBinding(sfbean.getDataBinding());
sfbean.setAddress("local://ExceptionServiceJaxWs");
Server server = sfbean.create();
Service service = server.getEndpoint().getService();
service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
proxyFac.setAddress("local://ExceptionServiceJaxWs");
proxyFac.setServiceClass(ExceptionService.class);
proxyFac.setBus(getBus());
proxyFac.getClientFactoryBean().getServiceFactory().setDataBinding(new AegisDatabinding());
ExceptionService clientInterface = (ExceptionService) proxyFac.create();
clientInterface.sayHiWithException();
}
Aggregations