Search in sources :

Example 1 with HeaderManager

use of org.apache.cxf.headers.HeaderManager in project BIMserver by opensourceBIM.

the class GenericWebServiceServlet method loadBus.

public void loadBus(ServletConfig servletConfig) {
    this.bus = BusFactory.newInstance().createBus();
    Bus bus = getBus();
    HeaderManager headerManager = bus.getExtension(HeaderManager.class);
    headerManager.registerHeaderProcessor(new HeaderProcessor() {

        @Override
        public String getNamespace() {
            return "uri:org.bimserver.shared";
        }

        @Override
        public InterceptorProvider getInterceptorProvider() {
            return null;
        }

        @Override
        public DataBinding getDataBinding() {
            try {
                return new JAXBDataBinding(Token.class);
            } catch (JAXBException e) {
                LOGGER.error("", e);
            }
            return null;
        }
    });
    BusFactory.setDefaultBus(bus);
    for (Class<? extends PublicInterface> clazz : getBimServer().getServicesMap().getInterfaceClasses()) {
        JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("mtom-enabled", Boolean.TRUE);
        serverFactoryBean.setBindingId(bindingId);
        serverFactoryBean.setProperties(properties);
        serverFactoryBean.setServiceClass(clazz);
        serverFactoryBean.getOutFaultInterceptors().add(new StatusCodeModifyingFaultInterceptor());
        serverFactoryBean.setInvoker(new CustomInvoker(getBimServer().getServiceFactory(), clazz));
        if (getBimServer().getConfig().getEnvironment() != Environment.WAR) {
            // equals check allowed, just keep using the constant
            serverFactoryBean.setAddress((bindingId == WSDLConstants.NS_SOAP11 ? "/soap11/" : "/soap12/") + clazz.getSimpleName());
        } else {
            // equals check allowed, just keep using the constant
            serverFactoryBean.setAddress("/" + clazz.getSimpleName());
        }
        serverFactoryBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
        serverFactoryBean.create();
    }
}
Also used : Bus(org.apache.cxf.Bus) HeaderProcessor(org.apache.cxf.headers.HeaderProcessor) HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) Token(org.bimserver.shared.Token) HeaderManager(org.apache.cxf.headers.HeaderManager) CustomInvoker(org.bimserver.webservices.CustomInvoker) DataBinding(org.apache.cxf.databinding.DataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

HashMap (java.util.HashMap)1 JAXBException (javax.xml.bind.JAXBException)1 Bus (org.apache.cxf.Bus)1 DataBinding (org.apache.cxf.databinding.DataBinding)1 HeaderManager (org.apache.cxf.headers.HeaderManager)1 HeaderProcessor (org.apache.cxf.headers.HeaderProcessor)1 InterceptorProvider (org.apache.cxf.interceptor.InterceptorProvider)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)1 Token (org.bimserver.shared.Token)1 CustomInvoker (org.bimserver.webservices.CustomInvoker)1