use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project cxf by apache.
the class ReflectionServiceFactoryTest method createService.
private Service createService(boolean wrapped) throws JAXBException {
serviceFactory = new ReflectionServiceFactoryBean();
serviceFactory.setBus(getBus());
serviceFactory.setServiceClass(HelloService.class);
serviceFactory.setWrapped(wrapped);
Map<String, Object> props = new HashMap<>();
props.put("test", "test");
serviceFactory.setProperties(props);
return serviceFactory.create();
}
use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testDocLiteralPartWithType.
@Test
public void testDocLiteralPartWithType() throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
serviceFactory.setBus(getBus());
serviceFactory.setServiceClass(NoBodyPartsImpl.class);
Service service = serviceFactory.create();
ServiceInfo serviceInfo = service.getServiceInfos().get(0);
QName qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1");
MessageInfo mi = serviceInfo.getMessage(qname);
qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "mimeAttachment");
MessagePartInfo mpi = mi.getMessagePart(qname);
QName elementQName = mpi.getElementQName();
XmlSchemaElement element = serviceInfo.getXmlSchemaCollection().getElementByQName(elementQName);
assertNotNull(element);
}
use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.
@Test
public void testWrappedDocLit() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
Service service = bean.create();
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
assertEquals("http://apache.org/hello_world_doc_lit", ns);
OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
assertNotNull(greetMeOp);
assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
MessagePartInfo inMessagePart = messageParts.get(0);
assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
// test output
messageParts = greetMeOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
MessagePartInfo outMessagePart = messageParts.get(0);
// assertEquals("result", outMessagePart.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
assertNull(greetMeOneWayOp.getOutput());
Collection<SchemaInfo> schemas = si.getSchemas();
assertEquals(1, schemas.size());
}
use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project cxf by apache.
the class ClientMtomXopTest method createPort.
private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM, boolean installInterceptors) throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
Bus bus = getStaticBus();
serviceFactory.setBus(bus);
serviceFactory.setServiceName(serviceName);
serviceFactory.setServiceClass(serviceEndpointInterface);
serviceFactory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl"));
Service service = serviceFactory.create();
EndpointInfo ei = service.getEndpointInfo(portName);
JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding(), jaxwsEndpoint);
jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
if (installInterceptors) {
// jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
}
jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor());
Client client = new ClientImpl(bus, jaxwsEndpoint);
InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
updateAddressPort(obj, PORT);
return serviceEndpointInterface.cast(obj);
}
use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project jbossws-cxf by jbossws.
the class BeanCustomizer method configureClientProxyFactoryBean.
/**
* Configure the client proxy factory; currently set the binding customization in the databinding (Client Side).
*
* @param factory
*/
protected void configureClientProxyFactoryBean(ClientProxyFactoryBean factory) {
// Configure binding customization
if (customization != null) {
// customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
serviceFactory.reset();
DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
configureBindingCustomization(serviceFactoryDataBinding, customization);
serviceFactory.setDataBinding(serviceFactoryDataBinding);
// customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one)
if (factory.getDataBinding() == null) {
// set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything
factory.setDataBinding(serviceFactoryDataBinding);
} else {
configureBindingCustomization(factory.getDataBinding(), customization);
}
}
// add other configurations here below
}
Aggregations