Search in sources :

Example 31 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class SoapBindingFactory method createSoapBinding.

private void createSoapBinding(final SoapBindingInfo bi) throws WSDLException {
    boolean isSoap12 = bi.getSoapVersion() instanceof Soap12;
    Bus bs = getBus();
    WSDLManager m = bs.getExtension(WSDLManager.class);
    ExtensionRegistry extensionRegistry = m.getExtensionRegistry();
    SoapBinding soapBinding = SOAPBindingUtil.createSoapBinding(extensionRegistry, isSoap12);
    soapBinding.setStyle(bi.getStyle());
    soapBinding.setTransportURI(bi.getTransportURI());
    bi.addExtensor(soapBinding);
    for (BindingOperationInfo b : bi.getOperations()) {
        for (BindingFaultInfo faultInfo : b.getFaults()) {
            SoapFault soapFault = SOAPBindingUtil.createSoapFault(extensionRegistry, isSoap12);
            soapFault.setUse("literal");
            soapFault.setName(faultInfo.getFaultInfo().getFaultName().getLocalPart());
            faultInfo.addExtensor(soapFault);
        }
        SoapOperationInfo soi = b.getExtensor(SoapOperationInfo.class);
        SoapOperation soapOperation = SOAPBindingUtil.createSoapOperation(extensionRegistry, isSoap12);
        soapOperation.setSoapActionURI(soi.getAction());
        soapOperation.setStyle(soi.getStyle());
        boolean isRpc = "rpc".equals(soapOperation.getStyle());
        b.addExtensor(soapOperation);
        if (b.getInput() != null) {
            List<String> bodyParts = null;
            List<SoapHeaderInfo> headerInfos = b.getInput().getExtensors(SoapHeaderInfo.class);
            if (headerInfos != null && !headerInfos.isEmpty()) {
                bodyParts = new ArrayList<>();
                for (MessagePartInfo part : b.getInput().getMessageParts()) {
                    bodyParts.add(part.getName().getLocalPart());
                }
                for (SoapHeaderInfo headerInfo : headerInfos) {
                    SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingInput.class, isSoap12);
                    soapHeader.setMessage(b.getInput().getMessageInfo().getName());
                    soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
                    soapHeader.setUse("literal");
                    bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
                    headerInfo.getPart().setProperty(HEADER, true);
                    b.getInput().addExtensor(soapHeader);
                }
            }
            SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingInput.class, isSoap12);
            body.setUse("literal");
            if (isRpc) {
                body.setNamespaceURI(b.getName().getNamespaceURI());
            }
            if (bodyParts != null) {
                body.setParts(bodyParts);
            }
            b.getInput().addExtensor(body);
        }
        if (b.getOutput() != null) {
            List<String> bodyParts = null;
            List<SoapHeaderInfo> headerInfos = b.getOutput().getExtensors(SoapHeaderInfo.class);
            if (headerInfos != null && !headerInfos.isEmpty()) {
                bodyParts = new ArrayList<>();
                for (MessagePartInfo part : b.getOutput().getMessageParts()) {
                    bodyParts.add(part.getName().getLocalPart());
                }
                for (SoapHeaderInfo headerInfo : headerInfos) {
                    SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingOutput.class, isSoap12);
                    soapHeader.setMessage(b.getOutput().getMessageInfo().getName());
                    soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
                    soapHeader.setUse("literal");
                    bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
                    b.getOutput().addExtensor(soapHeader);
                }
            }
            SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingOutput.class, isSoap12);
            body.setUse("literal");
            if (isRpc) {
                body.setNamespaceURI(b.getName().getNamespaceURI());
            }
            if (bodyParts != null) {
                body.setParts(bodyParts);
            }
            b.getOutput().addExtensor(body);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) SoapHeaderInfo(org.apache.cxf.binding.soap.model.SoapHeaderInfo) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry) WSDLManager(org.apache.cxf.wsdl.WSDLManager) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 32 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class SoapBindingFactory method createBindingInfo.

public BindingInfo createBindingInfo(ServiceInfo service, javax.wsdl.Binding binding, String ns) {
    SoapBindingInfo bi = new SoapBindingInfo(service, ns);
    // Copy all the extensors
    initializeBindingInfo(service, binding, bi);
    SoapBinding wSoapBinding = SOAPBindingUtil.getSoapBinding(bi.getExtensors(ExtensibilityElement.class));
    bi.setTransportURI(wSoapBinding.getTransportURI());
    bi.setStyle(wSoapBinding.getStyle());
    for (BindingOperationInfo boi : bi.getOperations()) {
        initializeBindingOperation(bi, boi);
    }
    return bi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 33 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class SoapBindingFactory method createBinding.

public Binding createBinding(BindingInfo binding) {
    // The default style should be doc-lit wrapped.
    String parameterStyle = SoapBindingConstants.PARAMETER_STYLE_WRAPPED;
    String bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;
    boolean hasWrapped = false;
    org.apache.cxf.binding.soap.SoapBinding sb = null;
    SoapVersion version = null;
    if (binding instanceof SoapBindingInfo) {
        SoapBindingInfo sbi = (SoapBindingInfo) binding;
        version = sbi.getSoapVersion();
        sb = new org.apache.cxf.binding.soap.SoapBinding(binding, version);
        // Service wide style
        if (!StringUtils.isEmpty(sbi.getStyle())) {
            bindingStyle = sbi.getStyle();
        }
        boolean hasRPC = false;
        boolean hasDoc = false;
        // Operation wide style, what to do with the mixed style/use?
        for (BindingOperationInfo boi : sbi.getOperations()) {
            String st = sbi.getStyle(boi.getOperationInfo());
            if (st != null) {
                bindingStyle = st;
                if (SoapBindingConstants.BINDING_STYLE_RPC.equalsIgnoreCase(st)) {
                    hasRPC = true;
                } else {
                    hasDoc = true;
                }
            }
            if (boi.getUnwrappedOperation() == null) {
                parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
            } else {
                hasWrapped = true;
            }
        }
        if (Boolean.TRUE.equals(binding.getService().getProperty("soap.force.doclit.bare"))) {
            hasDoc = true;
            hasRPC = false;
            parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
            bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;
        }
        if (hasRPC && hasDoc) {
            throw new RuntimeException("WSI-BP prohibits RPC and Document style " + "operations in same service.");
        }
        // jms
        if (sbi.getTransportURI().equals(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID)) {
            sb.getInInterceptors().add(new SoapJMSInInterceptor());
        }
    } else {
        throw new RuntimeException("Can not initialize SoapBinding, BindingInfo is not SoapBindingInfo");
    }
    sb.getOutFaultInterceptors().add(new StaxOutInterceptor());
    sb.getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));
    sb.getOutFaultInterceptors().add(new AttachmentOutInterceptor());
    sb.getInInterceptors().add(new AttachmentInInterceptor());
    sb.getInInterceptors().add(new StaxInInterceptor());
    sb.getInInterceptors().add(new SoapActionInInterceptor());
    sb.getOutInterceptors().add(new AttachmentOutInterceptor());
    sb.getOutInterceptors().add(new StaxOutInterceptor());
    sb.getOutInterceptors().add(SoapHeaderOutFilterInterceptor.INSTANCE);
    if (SoapBindingConstants.BINDING_STYLE_RPC.equalsIgnoreCase(bindingStyle)) {
        sb.getInInterceptors().add(new RPCInInterceptor());
        sb.getOutInterceptors().add(new RPCOutInterceptor());
    } else if (SoapBindingConstants.BINDING_STYLE_DOC.equalsIgnoreCase(bindingStyle) && SoapBindingConstants.PARAMETER_STYLE_BARE.equalsIgnoreCase(parameterStyle)) {
        // sb.getInInterceptors().add(new BareInInterceptor());
        sb.getInInterceptors().add(new DocLiteralInInterceptor());
        if (hasWrapped) {
            sb.getOutInterceptors().add(new WrappedOutInterceptor());
        }
        sb.getOutInterceptors().add(new BareOutInterceptor());
    } else {
        // sb.getInInterceptors().add(new WrappedInInterceptor());
        sb.getInInterceptors().add(new DocLiteralInInterceptor());
        sb.getOutInterceptors().add(new WrappedOutInterceptor());
        sb.getOutInterceptors().add(new BareOutInterceptor());
    }
    sb.getInInterceptors().add(new SoapHeaderInterceptor());
    sb.getInInterceptors().add(new ReadHeadersInterceptor(getBus(), version));
    sb.getInInterceptors().add(new StartBodyInterceptor());
    sb.getInInterceptors().add(new CheckFaultInterceptor());
    sb.getInInterceptors().add(new MustUnderstandInterceptor());
    sb.getOutInterceptors().add(new SoapPreProtocolOutInterceptor());
    sb.getOutInterceptors().add(new SoapOutInterceptor(getBus()));
    sb.getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));
    sb.getOutFaultInterceptors().add(SoapHeaderOutFilterInterceptor.INSTANCE);
    if (version.getVersion() == 1.1) {
        sb.getInFaultInterceptors().add(new Soap11FaultInInterceptor());
        sb.getOutFaultInterceptors().add(new Soap11FaultOutInterceptor());
    } else if (version.getVersion() == 1.2) {
        sb.getInFaultInterceptors().add(new Soap12FaultInInterceptor());
        sb.getOutFaultInterceptors().add(new Soap12FaultOutInterceptor());
    }
    if (binding.getService() != null) {
        for (EndpointInfo ei : binding.getService().getEndpoints()) {
            if (ei.getAddress() != null && ei.getAddress().startsWith("soap.udp")) {
                setupUDP(sb, ei);
            }
        }
    }
    return sb;
}
Also used : BareOutInterceptor(org.apache.cxf.wsdl.interceptors.BareOutInterceptor) ReadHeadersInterceptor(org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor) CheckFaultInterceptor(org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor) StaxOutInterceptor(org.apache.cxf.interceptor.StaxOutInterceptor) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapHeaderInterceptor(org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor) RPCOutInterceptor(org.apache.cxf.binding.soap.interceptor.RPCOutInterceptor) Soap12FaultInInterceptor(org.apache.cxf.binding.soap.interceptor.Soap12FaultInInterceptor) WrappedOutInterceptor(org.apache.cxf.wsdl.interceptors.WrappedOutInterceptor) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AttachmentInInterceptor(org.apache.cxf.interceptor.AttachmentInInterceptor) SoapJMSInInterceptor(org.apache.cxf.binding.soap.jms.interceptor.SoapJMSInInterceptor) DocLiteralInInterceptor(org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor) RPCInInterceptor(org.apache.cxf.binding.soap.interceptor.RPCInInterceptor) Soap11FaultInInterceptor(org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor) SoapOutInterceptor(org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor) SoapPreProtocolOutInterceptor(org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor) StaxInInterceptor(org.apache.cxf.interceptor.StaxInInterceptor) MustUnderstandInterceptor(org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor) Soap12FaultOutInterceptor(org.apache.cxf.binding.soap.interceptor.Soap12FaultOutInterceptor) StartBodyInterceptor(org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor) Soap11FaultOutInterceptor(org.apache.cxf.binding.soap.interceptor.Soap11FaultOutInterceptor) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapActionInInterceptor(org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor) AttachmentOutInterceptor(org.apache.cxf.interceptor.AttachmentOutInterceptor)

Example 34 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class FailoverTargetSelector method prepare.

/**
 * Called prior to the interceptor chain being traversed.
 *
 * @param message the current Message
 */
public void prepare(Message message) {
    if (message.getContent(List.class) == null) {
        return;
    }
    Exchange exchange = message.getExchange();
    setupExchangeExceptionProperties(exchange);
    InvocationKey key = new InvocationKey(exchange);
    if (getInvocationContext(key) == null) {
        if (getClientBootstrapAddress() != null && getClientBootstrapAddress().equals(message.get(Message.ENDPOINT_ADDRESS))) {
            List<String> addresses = failoverStrategy.getAlternateAddresses(exchange);
            if (addresses != null && !addresses.isEmpty()) {
                getEndpoint().getEndpointInfo().setAddress(addresses.get(0));
                message.put(Message.ENDPOINT_ADDRESS, addresses.get(0));
            }
        }
        Endpoint endpoint = exchange.getEndpoint();
        BindingOperationInfo bindingOperationInfo = exchange.getBindingOperationInfo();
        Object[] params = message.getContent(List.class).toArray();
        Map<String, Object> context = CastUtils.cast((Map<?, ?>) message.get(Message.INVOCATION_CONTEXT));
        InvocationContext invocation = new InvocationContext(endpoint, bindingOperationInfo, params, context);
        inProgress.putIfAbsent(key, invocation);
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) List(java.util.List)

Example 35 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.

the class DefaultLogEventMapper method getOperationName.

private String getOperationName(Message message) {
    String operationName = null;
    BindingOperationInfo boi = null;
    boi = message.getExchange().getBindingOperationInfo();
    if (null != boi) {
        operationName = boi.getName().toString();
    }
    return operationName;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo)

Aggregations

BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)214 QName (javax.xml.namespace.QName)82 BindingInfo (org.apache.cxf.service.model.BindingInfo)57 Test (org.junit.Test)55 Exchange (org.apache.cxf.message.Exchange)50 OperationInfo (org.apache.cxf.service.model.OperationInfo)47 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)42 Endpoint (org.apache.cxf.endpoint.Endpoint)41 Message (org.apache.cxf.message.Message)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)32 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)31 Service (org.apache.cxf.service.Service)29 Fault (org.apache.cxf.interceptor.Fault)24 MessageInfo (org.apache.cxf.service.model.MessageInfo)24 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Method (java.lang.reflect.Method)22 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)22 ArrayList (java.util.ArrayList)21 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)16