Search in sources :

Example 1 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)

Example 2 with ReflectionServiceFactoryBean

use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project jbossws-cxf by jbossws.

the class BeanCustomizer method configureEndpointFactory.

/**
 * Configure the endpoint factory
 *
 * @param factory
 */
protected void configureEndpointFactory(AbstractWSDLBasedEndpointFactory factory) {
    // Configure binding customization
    if (customization != null) {
        ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
        // customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
        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)

Example 3 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 4 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 5 with ReflectionServiceFactoryBean

use of org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean in project cxf by apache.

the class GreeterTest 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(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    Service service = bean.create();
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);
    svr.create();
    Node response = invoke("http://localhost:9000/SoapContext/SoapPort", LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
    assertEquals(1, greeter.getInvocationCount());
    assertNotNull(response);
    addNamespace("h", "http://apache.org/hello_world_soap_http/types");
    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Node(org.w3c.dom.Node) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)22 Service (org.apache.cxf.service.Service)14 Test (org.junit.Test)12 WebService (javax.jws.WebService)9 Bus (org.apache.cxf.Bus)9 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)9 QName (javax.xml.namespace.QName)6 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)6 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)6 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)6 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)6 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)6 URL (java.net.URL)5 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)5 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)5 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 OperationInfo (org.apache.cxf.service.model.OperationInfo)3