Search in sources :

Example 1 with PayLoadDataFormatFeature

use of org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature in project camel by apache.

the class CxfEndpoint method setupServerFactoryBean.

/**
     * Populate server factory bean
     */
protected void setupServerFactoryBean(ServerFactoryBean sfb, Class<?> cls) {
    // address
    sfb.setAddress(getAddress());
    sfb.setServiceClass(cls);
    sfb.setInInterceptors(in);
    sfb.setOutInterceptors(out);
    sfb.setOutFaultInterceptors(outFault);
    sfb.setInFaultInterceptors(inFault);
    sfb.setFeatures(features);
    if (schemaLocations != null) {
        sfb.setSchemaLocations(schemaLocations);
    }
    if (bindingConfig != null) {
        sfb.setBindingConfig(bindingConfig);
    }
    if (dataBinding != null) {
        sfb.setDataBinding(dataBinding);
    }
    if (serviceFactoryBean != null) {
        setServiceFactory(sfb, serviceFactoryBean);
    }
    if (sfb instanceof JaxWsServerFactoryBean && handlers != null) {
        ((JaxWsServerFactoryBean) sfb).setHandlers(handlers);
    }
    if (getTransportId() != null) {
        sfb.setTransportId(getTransportId());
    }
    if (getBindingId() != null) {
        sfb.setBindingId(getBindingId());
    }
    // wsdl url
    if (getWsdlURL() != null) {
        sfb.setWsdlURL(getWsdlURL());
    }
    // service  name qname
    if (getServiceName() != null) {
        sfb.setServiceName(getServiceName());
    }
    // port qname
    if (getPortName() != null) {
        sfb.setEndpointName(getPortName());
    }
    // apply feature here
    if (!CxfEndpointUtils.hasAnnotation(cls, WebServiceProvider.class)) {
        if (getDataFormat() == DataFormat.PAYLOAD) {
            sfb.getFeatures().add(new PayLoadDataFormatFeature(allowStreaming));
        } else if (getDataFormat().dealias() == DataFormat.CXF_MESSAGE) {
            sfb.getFeatures().add(new CXFMessageDataFormatFeature());
            sfb.setDataBinding(new SourceDataBinding());
        } else if (getDataFormat().dealias() == DataFormat.RAW) {
            RAWDataFormatFeature feature = new RAWDataFormatFeature();
            if (this.getExchangePattern().equals(ExchangePattern.InOnly)) {
                //if DataFormat is RAW|MESSAGE, can't read message so can't
                //determine it's oneway so need get the MEP from URI explicitly
                feature.setOneway(true);
            }
            feature.addInIntercepters(getInInterceptors());
            feature.addOutInterceptors(getOutInterceptors());
            sfb.getFeatures().add(feature);
        }
    } else {
        LOG.debug("Ignore DataFormat mode {} since SEI class is annotated with WebServiceProvider", getDataFormat());
    }
    if (isLoggingFeatureEnabled()) {
        if (getLoggingSizeLimit() != 0) {
            sfb.getFeatures().add(new LoggingFeature(getLoggingSizeLimit()));
        } else {
            sfb.getFeatures().add(new LoggingFeature());
        }
    }
    if (getDataFormat() == DataFormat.PAYLOAD) {
        sfb.setDataBinding(new HybridSourceDataBinding());
    }
    // set the document-literal wrapped style
    if (getWrappedStyle() != null && getDataFormat().dealias() != DataFormat.CXF_MESSAGE) {
        setWrapped(sfb, getWrappedStyle());
    }
    // any optional properties
    if (getProperties() != null) {
        if (sfb.getProperties() != null) {
            // add to existing properties
            sfb.getProperties().putAll(getProperties());
        } else {
            sfb.setProperties(getProperties());
        }
        LOG.debug("ServerFactoryBean: {} added properties: {}", sfb, getProperties());
    }
    if (this.isSkipPayloadMessagePartCheck()) {
        if (sfb.getProperties() == null) {
            sfb.setProperties(new HashMap<String, Object>());
        }
        sfb.getProperties().put("soap.no.validate.parts", Boolean.TRUE);
    }
    if (this.isSkipFaultLogging()) {
        if (sfb.getProperties() == null) {
            sfb.setProperties(new HashMap<String, Object>());
        }
        sfb.getProperties().put(FaultListener.class.getName(), new NullFaultListener());
    }
    sfb.setBus(getBus());
    sfb.setStart(false);
    getNullSafeCxfEndpointConfigurer().configure(sfb);
}
Also used : RAWDataFormatFeature(org.apache.camel.component.cxf.feature.RAWDataFormatFeature) FaultListener(org.apache.cxf.logging.FaultListener) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) WebServiceProvider(javax.xml.ws.WebServiceProvider) LoggingFeature(org.apache.cxf.feature.LoggingFeature) PayLoadDataFormatFeature(org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature) CXFMessageDataFormatFeature(org.apache.camel.component.cxf.feature.CXFMessageDataFormatFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 2 with PayLoadDataFormatFeature

use of org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature in project camel by apache.

the class CxfEndpoint method setupClientFactoryBean.

protected void setupClientFactoryBean(ClientFactoryBean factoryBean, Class<?> cls) {
    if (cls != null) {
        factoryBean.setServiceClass(cls);
    }
    factoryBean.setInInterceptors(in);
    factoryBean.setOutInterceptors(out);
    factoryBean.setOutFaultInterceptors(outFault);
    factoryBean.setInFaultInterceptors(inFault);
    factoryBean.setFeatures(features);
    factoryBean.setTransportId(transportId);
    factoryBean.setBindingId(bindingId);
    if (bindingConfig != null) {
        factoryBean.setBindingConfig(bindingConfig);
    }
    if (dataBinding != null) {
        factoryBean.setDataBinding(dataBinding);
    }
    if (serviceFactoryBean != null) {
        setServiceFactory(factoryBean, serviceFactoryBean);
    }
    // address
    factoryBean.setAddress(getAddress());
    // wsdl url
    if (getWsdlURL() != null) {
        factoryBean.setWsdlURL(getWsdlURL());
    }
    // service name qname
    if (getServiceName() != null) {
        factoryBean.setServiceName(getServiceName());
    }
    // port name qname
    if (getPortName() != null) {
        factoryBean.setEndpointName(getPortName());
    }
    // apply feature here
    if (getDataFormat().dealias() == DataFormat.RAW) {
        RAWDataFormatFeature feature = new RAWDataFormatFeature();
        feature.addInIntercepters(getInInterceptors());
        feature.addOutInterceptors(getOutInterceptors());
        factoryBean.getFeatures().add(feature);
    } else if (getDataFormat().dealias() == DataFormat.CXF_MESSAGE) {
        factoryBean.getFeatures().add(new CXFMessageDataFormatFeature());
        factoryBean.setDataBinding(new SourceDataBinding());
    } else if (getDataFormat() == DataFormat.PAYLOAD) {
        factoryBean.getFeatures().add(new PayLoadDataFormatFeature(allowStreaming));
        factoryBean.setDataBinding(new HybridSourceDataBinding());
    }
    if (isLoggingFeatureEnabled()) {
        if (getLoggingSizeLimit() != 0) {
            factoryBean.getFeatures().add(new LoggingFeature(getLoggingSizeLimit()));
        } else {
            factoryBean.getFeatures().add(new LoggingFeature());
        }
    }
    // set the document-literal wrapped style
    if (getWrappedStyle() != null) {
        setWrapped(factoryBean, getWrappedStyle());
    }
    // any optional properties
    if (getProperties() != null) {
        if (factoryBean.getProperties() != null) {
            // add to existing properties
            factoryBean.getProperties().putAll(getProperties());
        } else {
            factoryBean.setProperties(getProperties());
        }
        LOG.debug("ClientFactoryBean: {} added properties: {}", factoryBean, getProperties());
    }
    // setup the basic authentication property
    if (ObjectHelper.isNotEmpty(username)) {
        AuthorizationPolicy authPolicy = new AuthorizationPolicy();
        authPolicy.setUserName(username);
        authPolicy.setPassword(password);
        if (factoryBean.getProperties() == null) {
            factoryBean.setProperties(new HashMap<String, Object>());
        }
        factoryBean.getProperties().put(AuthorizationPolicy.class.getName(), authPolicy);
    }
    if (this.isSkipPayloadMessagePartCheck()) {
        if (factoryBean.getProperties() == null) {
            factoryBean.setProperties(new HashMap<String, Object>());
        }
        factoryBean.getProperties().put("soap.no.validate.parts", Boolean.TRUE);
    }
    if (this.isSkipFaultLogging()) {
        if (factoryBean.getProperties() == null) {
            factoryBean.setProperties(new HashMap<String, Object>());
        }
        factoryBean.getProperties().put(FaultListener.class.getName(), new NullFaultListener());
    }
    factoryBean.setBus(getBus());
    getNullSafeCxfEndpointConfigurer().configure(factoryBean);
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) RAWDataFormatFeature(org.apache.camel.component.cxf.feature.RAWDataFormatFeature) LoggingFeature(org.apache.cxf.feature.LoggingFeature) PayLoadDataFormatFeature(org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature) FaultListener(org.apache.cxf.logging.FaultListener) CXFMessageDataFormatFeature(org.apache.camel.component.cxf.feature.CXFMessageDataFormatFeature) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding)

Aggregations

CXFMessageDataFormatFeature (org.apache.camel.component.cxf.feature.CXFMessageDataFormatFeature)2 PayLoadDataFormatFeature (org.apache.camel.component.cxf.feature.PayLoadDataFormatFeature)2 RAWDataFormatFeature (org.apache.camel.component.cxf.feature.RAWDataFormatFeature)2 SourceDataBinding (org.apache.cxf.databinding.source.SourceDataBinding)2 LoggingFeature (org.apache.cxf.feature.LoggingFeature)2 FaultListener (org.apache.cxf.logging.FaultListener)2 WebServiceProvider (javax.xml.ws.WebServiceProvider)1 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)1 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)1