Search in sources :

Example 1 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ProviderImpl method createEndpoint.

// new in 2.2
public Endpoint createEndpoint(String bindingId, Class<?> implementorClass, Invoker invoker, WebServiceFeature... features) {
    if (EndpointUtils.isValidImplementor(implementorClass)) {
        Bus bus = BusFactory.getThreadDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        if (features != null) {
            factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features));
        }
        if (invoker != null) {
            factory.setInvoker(new JAXWSMethodInvoker(invoker));
            try {
                invoker.inject(new WebServiceContextImpl());
            } catch (Exception e) {
                throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG", LOG).toString(), e);
            }
        }
        EndpointImpl ep = new EndpointImpl(bus, null, factory);
        ep.setImplementorClass(implementorClass);
        return ep;
    }
    throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
}
Also used : Bus(org.apache.cxf.Bus) WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.common.i18n.Message) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) WebServiceContextImpl(org.apache.cxf.jaxws.context.WebServiceContextImpl) XMLStreamException(javax.xml.stream.XMLStreamException) PrivilegedActionException(java.security.PrivilegedActionException) JAXBException(javax.xml.bind.JAXBException) WebServiceException(javax.xml.ws.WebServiceException)

Example 2 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ProviderServiceFactoryTest method testSOAPBindingFromCode.

@Test
public void testSOAPBindingFromCode() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(SOAPSourcePayloadProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider()));
    Service service = bean.create();
    assertEquals("SOAPSourcePayloadProviderService", service.getName().getLocalPart());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    assertEquals(1, intf.getOperations().size());
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(getBus());
    svrFactory.setServiceFactory(bean);
    String address = "local://localhost:9000/test";
    svrFactory.setAddress(address);
    ServerImpl server = (ServerImpl) svrFactory.create();
    // See if our endpoint was created correctly
    assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof SoapBinding);
    SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
    assertEquals("document", sb.getStyle());
    assertEquals(false, bean.isWrapped());
    assertEquals(1, sb.getOperations().size());
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
    addNamespace("j", "http://service.jaxws.cxf.apache.org/");
    assertValid("/s:Envelope/s:Body/j:sayHi", res);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 3 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class MEXInInterceptor method createEndpoint.

private synchronized Endpoint createEndpoint(Message message) {
    if (mexEndpoint == null) {
        MEXJaxWsServerFactoryBean factory = new MEXJaxWsServerFactoryBean(message.getExchange().getBus());
        try {
            Endpoint endpoint = factory.createEndpoint();
            endpoint.getService().setInvoker(new JAXWSMethodInvoker(ep));
            mexEndpoint = endpoint;
        } catch (Exception ex) {
            throw new Fault(ex);
        }
    }
    return mexEndpoint;
}
Also used : Endpoint(org.apache.cxf.endpoint.Endpoint) Fault(org.apache.cxf.interceptor.Fault) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) BusException(org.apache.cxf.BusException) EndpointException(org.apache.cxf.endpoint.EndpointException)

Example 4 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ProviderServiceFactoryTest method testFromWSDL.

@Test
public void testFromWSDL() throws Exception {
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(HWSoapMessageProvider.class);
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(implInfo);
    bean.setWsdlURL(resource.toString());
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(HWSoapMessageProvider.class);
    Service service = bean.create();
    assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker);
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setStart(false);
    ServerImpl server = (ServerImpl) svrFactory.create();
    assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker);
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof SoapBinding);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) Bus(org.apache.cxf.Bus) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) URL(java.net.URL) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 5 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ServerMisc method run.

protected void run() {
    Factory factory = new PerRequestFactory(DocLitWrappedCodeFirstServiceImpl.class);
    factory = new PooledFactory(factory, 4);
    JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory);
    JaxWsServerFactoryBean factoryBean;
    Map<String, Object> properties = new HashMap<>();
    properties.put("bus.jmx.usePlatformMBeanServer", Boolean.TRUE);
    properties.put("bus.jmx.enabled", Boolean.TRUE);
    Bus b = new CXFBusFactory().createBus(null, properties);
    setBus(b);
    MetricRegistry registry = new MetricRegistry();
    CodahaleMetricsProvider.setupJMXReporter(b, registry);
    b.setExtension(registry, MetricRegistry.class);
    factoryBean = new JaxWsServerFactoryBean();
    factoryBean.setBus(b);
    factoryBean.setAddress(DOCLIT_CODEFIRST_URL);
    factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
    factoryBean.setFeatures(Arrays.asList(new MetricsFeature()));
    factoryBean.setInvoker(invoker);
    servers.add(factoryBean.create());
    factoryBean = new JaxWsServerFactoryBean();
    factoryBean.setBus(b);
    factoryBean.setAddress(DOCLIT_CODEFIRST_URL_XMLBINDING);
    factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
    factoryBean.setFeatures(Arrays.asList(new MetricsFeature()));
    factoryBean.setInvoker(invoker);
    factoryBean.setBindingId("http://cxf.apache.org/bindings/xformat");
    factoryBean.setWsdlURL("cxf6866.wsdl");
    servers.add(factoryBean.create());
    factoryBean = new JaxWsServerFactoryBean();
    factoryBean.setAddress(DOCLIT_CODEFIRST_SETTINGS_URL);
    factoryBean.setServiceClass(DocLitWrappedCodeFirstServiceImpl.class);
    factoryBean.setInvoker(invoker);
    factoryBean.getServiceFactory().setAnonymousWrapperTypes(true);
    factoryBean.getServiceFactory().getServiceConfigurations().add(0, new AbstractServiceConfiguration() {

        public Boolean isWrapperPartNillable(MessagePartInfo mpi) {
            return Boolean.TRUE;
        }

        public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
            return Long.valueOf(1L);
        }
    });
    servers.add(factoryBean.create());
    // Object implementor4 = new DocLitWrappedCodeFirstServiceImpl();
    // endpoints.add(Endpoint.publish(DOCLIT_CODEFIRST_URL, implementor4));
    Object implementor7 = new DocLitBareCodeFirstServiceImpl();
    EndpointImpl ep = (EndpointImpl) Endpoint.publish(DOCLITBARE_CODEFIRST_URL, implementor7);
    ep.getServer().getEndpoint().getInInterceptors().add(new SAAJInInterceptor());
    endpoints.add(ep);
    Object implementor6 = new InterfaceInheritTestImpl();
    endpoints.add(Endpoint.publish(DOCLIT_CODEFIRST_BASE_URL, implementor6));
    Object implementor1 = new AnonymousComplexTypeImpl();
    String address = "http://localhost:" + PORT + "/anonymous_complex_typeSOAP";
    endpoints.add(Endpoint.publish(address, implementor1));
    Object implementor2 = new JaxbElementTestImpl();
    address = "http://localhost:" + PORT + "/jaxb_element_test";
    endpoints.add(Endpoint.publish(address, implementor2));
    Object implementor3 = new OrderedParamHolderImpl();
    address = "http://localhost:" + PORT + "/ordered_param_holder/";
    endpoints.add(Endpoint.publish(address, implementor3));
    // Object implementor4 = new DocLitWrappedCodeFirstServiceImpl();
    // endpoints.add(Endpoint.publish(DOCLIT_CODEFIRST_URL, implementor4));
    Object implementor5 = new RpcLitCodeFirstServiceImpl();
    endpoints.add(Endpoint.publish(RPCLIT_CODEFIRST_URL, implementor5));
    endpoints.add(Endpoint.publish("http://localhost:" + PORT + "/InheritContext/InheritPort", new InheritImpl()));
    endpoints.add(Endpoint.publish(CXF_5064_URL, new SOAPHeaderServiceImpl()));
}
Also used : HashMap(java.util.HashMap) MetricsFeature(org.apache.cxf.metrics.MetricsFeature) Factory(org.apache.cxf.service.invoker.Factory) PooledFactory(org.apache.cxf.service.invoker.PooledFactory) PerRequestFactory(org.apache.cxf.service.invoker.PerRequestFactory) CXFBusFactory(org.apache.cxf.bus.CXFBusFactory) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) PooledFactory(org.apache.cxf.service.invoker.PooledFactory) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) CXFBusFactory(org.apache.cxf.bus.CXFBusFactory) JaxbElementTestImpl(org.apache.cxf.jaxb_element_test.JaxbElementTestImpl) Bus(org.apache.cxf.Bus) SOAPHeaderServiceImpl(org.apache.cxf.systest.jaxws.cxf5064.SOAPHeaderServiceImpl) MetricRegistry(com.codahale.metrics.MetricRegistry) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) AbstractServiceConfiguration(org.apache.cxf.wsdl.service.factory.AbstractServiceConfiguration) AnonymousComplexTypeImpl(org.apache.cxf.anonymous_complex_type.AnonymousComplexTypeImpl) OrderedParamHolderImpl(org.apache.cxf.ordered_param_holder.OrderedParamHolderImpl) PerRequestFactory(org.apache.cxf.service.invoker.PerRequestFactory)

Aggregations

JAXWSMethodInvoker (org.apache.cxf.jaxws.JAXWSMethodInvoker)7 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)6 Endpoint (org.apache.cxf.endpoint.Endpoint)5 Binding (org.apache.cxf.binding.Binding)4 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)4 XMLBinding (org.apache.cxf.binding.xml.XMLBinding)4 ServerImpl (org.apache.cxf.endpoint.ServerImpl)4 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)4 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)4 Service (org.apache.cxf.service.Service)4 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)4 Test (org.junit.Test)4 Bus (org.apache.cxf.Bus)3 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)2 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)2 Node (org.w3c.dom.Node)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 URL (java.net.URL)1 PrivilegedActionException (java.security.PrivilegedActionException)1 HashMap (java.util.HashMap)1