Search in sources :

Example 6 with ReflectionServiceFactoryBean

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();
}
Also used : HashMap(java.util.HashMap) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

Example 7 with ReflectionServiceFactoryBean

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);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 8 with ReflectionServiceFactoryBean

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());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 9 with ReflectionServiceFactoryBean

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);
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Service(org.apache.cxf.service.Service) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ClientImpl(org.apache.cxf.endpoint.ClientImpl) InvocationHandler(java.lang.reflect.InvocationHandler) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) JaxWsClientProxy(org.apache.cxf.jaxws.JaxWsClientProxy) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) SOAPBindingImpl(org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl) Client(org.apache.cxf.endpoint.Client) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

Example 10 with ReflectionServiceFactoryBean

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
}
Also used : DataBinding(org.apache.cxf.databinding.DataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

Aggregations

ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)21 Service (org.apache.cxf.service.Service)13 Test (org.junit.Test)11 WebService (javax.jws.WebService)9 Bus (org.apache.cxf.Bus)9 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)8 QName (javax.xml.namespace.QName)6 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)6 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)6 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)6 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)5 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)5 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)5 URL (java.net.URL)4 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)4 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)4 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)3 ClientImpl (org.apache.cxf.endpoint.ClientImpl)3 BindingInfo (org.apache.cxf.service.model.BindingInfo)3 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3