Search in sources :

Example 56 with JaxWsServerFactoryBean

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

the class ManagedBusTest method testTwoSameNamedEndpoint.

@Test
public void testTwoSameNamedEndpoint() throws Exception {
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus();
    try {
        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
        assertNotNull(im);
        InstrumentationManagerImpl imi = (InstrumentationManagerImpl) im;
        imi.setServer(ManagementFactory.getPlatformMBeanServer());
        imi.setEnabled(true);
        imi.init();
        Greeter greeter1 = new GreeterImpl();
        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
        svrFactory.setServiceBean(greeter1);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
        svrFactory.create();
        Greeter greeter2 = new GreeterImpl();
        svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
        svrFactory.setServiceBean(greeter2);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
        svrFactory.create();
        MBeanServer mbs = im.getMBeanServer();
        ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*");
        Set<?> s = mbs.queryMBeans(name, null);
        assertEquals(2, s.size());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 57 with JaxWsServerFactoryBean

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

the class MtomPolicyTest method setupServer.

public void setupServer(boolean mtomRequired, String address) throws Exception {
    getStaticBus().getExtension(PolicyEngine.class).setAlternativeSelector(new FirstAlternativeSelector());
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceBean(new EchoService());
    sf.setBus(getStaticBus());
    sf.setAddress(address);
    WSPolicyFeature policyFeature = new WSPolicyFeature();
    List<Element> policyElements = new ArrayList<>();
    if (mtomRequired) {
        policyElements.add(StaxUtils.read(getClass().getResourceAsStream("mtom-policy.xml")).getDocumentElement());
    } else {
        policyElements.add(StaxUtils.read(getClass().getResourceAsStream("mtom-policy-optional.xml")).getDocumentElement());
    }
    policyFeature.setPolicyElements(policyElements);
    sf.getFeatures().add(policyFeature);
    sf.create();
}
Also used : FirstAlternativeSelector(org.apache.cxf.ws.policy.selector.FirstAlternativeSelector) WSPolicyFeature(org.apache.cxf.ws.policy.WSPolicyFeature) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 58 with JaxWsServerFactoryBean

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

the class Server11 method run.

protected void run() {
    Object implementor = new GreeterImpl11();
    String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";
    // enable the options of stack trace and the exception cause message
    Map<String, Object> properties = new HashMap<>();
    properties.put("exceptionMessageCauseEnabled", "true");
    properties.put("faultStackTraceEnabled", "true");
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setAddress(address);
    factory.setServiceBean(implementor);
    factory.setProperties(properties);
    factory.create();
}
Also used : HashMap(java.util.HashMap) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 59 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project nutzboot by nutzam.

the class CxfStarter method loadBus.

protected void loadBus(ServletConfig sc) {
    super.loadBus(sc);
    for (Class<?> klass : Scans.me().scanPackage(appContext.getPackage(), null)) {
        // 有@WebService和@IocBean注解的非接口类
        WebService ws = klass.getAnnotation(WebService.class);
        if (ws == null || klass.isInterface())
            continue;
        if (Strings.isBlank(ws.serviceName())) {
            log.infof("%s has @WebService but serviceName is blank, ignore", klass.getName());
            continue;
        }
        log.debugf("add WebService addr=/%s type=%s", ws.serviceName(), klass.getName());
        JaxWsServerFactoryBean sfb = new JaxWsServerFactoryBean();
        sfb.setServiceBean(ioc.get(klass));
        sfb.create();
    }
}
Also used : WebService(javax.jws.WebService) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 60 with JaxWsServerFactoryBean

use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project Activiti by Activiti.

the class AbstractWebServiceTaskTest method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();
    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress(WEBSERVICE_MOCK_ADDRESS);
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)106 Server (org.apache.cxf.endpoint.Server)32 Test (org.junit.Test)29 Service (org.apache.cxf.service.Service)21 Bus (org.apache.cxf.Bus)15 HashMap (java.util.HashMap)13 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)13 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)13 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)9 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)8 QName (javax.xml.namespace.QName)7 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 BeforeClass (org.junit.BeforeClass)7 Endpoint (org.apache.cxf.endpoint.Endpoint)6 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)6 JAXWSMethodInvoker (org.apache.cxf.jaxws.JAXWSMethodInvoker)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)6 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)5 URL (java.net.URL)4 Definition (javax.wsdl.Definition)4