Search in sources :

Example 1 with HTTPBinding

use of javax.wsdl.extensions.http.HTTPBinding in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getHttpBindingOperations.

/**
 * Retrieves all the operations defined in the provided Binding.
 *
 * @param binding WSDL binding
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
    Set<WSDLOperation> allBindingOperations = new HashSet<>();
    if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
        if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
            HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
            String verb = httpBinding.getVerb();
            for (Object opObj : binding.getBindingOperations()) {
                if (opObj instanceof BindingOperation) {
                    BindingOperation bindingOperation = (BindingOperation) opObj;
                    WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
                    if (wsdlOperation != null) {
                        allBindingOperations.add(wsdlOperation);
                    }
                }
            }
        }
    }
    return allBindingOperations;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) HashSet(java.util.HashSet)

Example 2 with HTTPBinding

use of javax.wsdl.extensions.http.HTTPBinding in project carbon-business-process by wso2.

the class PartnerService method invoke.

public void invoke(final PartnerRoleMessageExchange partnerRoleMessageExchange) {
    boolean isTwoWay = (partnerRoleMessageExchange.getMessageExchangePattern() == MessageExchange.MessageExchangePattern.REQUEST_RESPONSE);
    try {
        // Override options are passed to the axis MessageContext so we can
        // retrieve them in our session out changeHandler
        // 
        // Below logic is required only if tenant information from the thread local context is required here.
        // However,
        // it does not seem required, hence commenting out.
        String deployer = processConfiguration.getDeployer();
        if (log.isDebugEnabled()) {
            String msg = "Process Name => " + processConfiguration.getProcessId() + " Deployer =>" + processConfiguration.getDeployer();
            log.debug(msg);
        }
        PrivilegedCarbonContext.startTenantFlow();
        // Assuming that deployer should not be null
        String domain = BPELServerHolder.getInstance().getRealmService().getTenantManager().getDomain(Integer.parseInt(deployer));
        if (domain != null) {
            PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(domain);
            PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(Integer.parseInt(deployer));
        } else {
            PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
            PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(Integer.parseInt(deployer));
        }
        final MessageContext mctx = new MessageContext();
        BPELMessageContext partnerInvocationContext = BPELMessageContextFactory.createBPELMessageContext(mctx, this);
        ExtensibilityElement bindingType = WSDLAwareSOAPProcessor.getBindingExtension(binding);
        try {
            if (bindingType instanceof HTTPBinding) {
                // =========================================================
                if (uep.getAddress() == null) {
                    uep.setAddress(endpointUrl);
                }
                partnerInvocationContext.setUep(uep);
                partnerInvocationContext.setTwoWay(isTwoWay);
                partnerInvocationContext.setService(serviceName);
                partnerInvocationContext.setPort(portName);
                partnerInvocationContext.setCaller(partnerRoleMessageExchange.getCaller().getLocalPart());
                partnerInvocationContext.setOperationName(partnerRoleMessageExchange.getOperationName());
                SOAPUtils.createSOAPRequest(partnerInvocationContext, partnerRoleMessageExchange);
                String mexEndpointUrl = ((MutableEndpoint) partnerRoleMessageExchange.getEndpointReference()).getUrl();
                if (!endpointUrl.equals(mexEndpointUrl)) {
                    uep.setAddress(mexEndpointUrl);
                }
                if (messageTraceLog.isDebugEnabled()) {
                    messageTraceLog.debug("Invoking service: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
                    if (messageTraceLog.isTraceEnabled()) {
                        messageTraceLog.trace("Request message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + partnerInvocationContext.getInMessageContext().getEnvelope());
                    }
                }
                HTTPBindingHandler httpBindingHandler = new HTTPBindingHandler(clientConfigCtx, serviceName, portName, wsdlDefinition);
                HTTPBindingHandler.HTTPBindingResponse response = httpBindingHandler.invoke(partnerRoleMessageExchange, partnerInvocationContext);
                if (isTwoWay) {
                    MessageContext responseMessageContext = response.getReponseMessageContext();
                    partnerInvocationContext.setOutMessageContext(responseMessageContext);
                    MessageContext fltMessageContext = response.getFaultMessageContext();
                    if (messageTraceLog.isTraceEnabled()) {
                        messageTraceLog.trace("Response message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + responseMessageContext.getEnvelope());
                    }
                    if (fltMessageContext != null) {
                        replyHTTP(partnerInvocationContext, partnerRoleMessageExchange, true);
                    } else {
                        replyHTTP(partnerInvocationContext, partnerRoleMessageExchange, response.isFault());
                    }
                } else {
                    /* one-way case */
                    partnerRoleMessageExchange.replyOneWayOk();
                }
            } else {
                if (uep.getAddress() == null) {
                    uep.setAddress(endpointUrl);
                }
                partnerInvocationContext.setUep(uep);
                partnerInvocationContext.setTwoWay(isTwoWay);
                partnerInvocationContext.setService(serviceName);
                partnerInvocationContext.setPort(portName);
                partnerInvocationContext.setCaller(partnerRoleMessageExchange.getCaller().getLocalPart());
                partnerInvocationContext.setOperationName(partnerRoleMessageExchange.getOperationName());
                SOAPUtils.createSOAPRequest(partnerInvocationContext, partnerRoleMessageExchange);
                String mexEndpointUrl = ((MutableEndpoint) partnerRoleMessageExchange.getEndpointReference()).getUrl();
                if (!endpointUrl.equals(mexEndpointUrl)) {
                    uep.setAddress(mexEndpointUrl);
                }
                if (messageTraceLog.isDebugEnabled()) {
                    messageTraceLog.debug("Invoking service: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
                    if (messageTraceLog.isTraceEnabled()) {
                        messageTraceLog.trace("Request message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + partnerInvocationContext.getInMessageContext().getEnvelope());
                    }
                }
                AxisServiceUtils.invokeService(partnerInvocationContext, clientConfigCtx);
                if (messageTraceLog.isDebugEnabled()) {
                    messageTraceLog.debug("Service invocation completed: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + serviceName + "." + partnerRoleMessageExchange.getOperationName());
                }
                if (isTwoWay) {
                    final Operation operation = partnerRoleMessageExchange.getOperation();
                    MessageContext response = partnerInvocationContext.getOutMessageContext();
                    MessageContext flt = partnerInvocationContext.getFaultMessageContext();
                    if (messageTraceLog.isTraceEnabled()) {
                        messageTraceLog.trace("Response message: MEXId: " + partnerRoleMessageExchange.getMessageExchangeId() + " :: " + response.getEnvelope());
                    }
                    if (flt != null) {
                        reply(partnerInvocationContext, partnerRoleMessageExchange, operation, flt, true);
                    } else {
                        reply(partnerInvocationContext, partnerRoleMessageExchange, operation, response, response.isFault());
                    }
                } else {
                    /* one-way case */
                    partnerRoleMessageExchange.replyOneWayOk();
                }
            }
        } finally {
            // make sure the HTTP connection is released to the pool!
            TransportOutDescription out = mctx.getTransportOut();
            if (out != null && out.getSender() != null) {
                out.getSender().cleanup(mctx);
            }
        }
    } catch (Exception e) {
        String errmsg = Messages.msgErrorSendingMessageToAxisForODEMex(partnerRoleMessageExchange.toString());
        log.error(errmsg, e);
        replyWithFailure(partnerRoleMessageExchange, MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
Also used : MessageContext(org.apache.axis2.context.MessageContext) Operation(javax.wsdl.Operation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) MutableEndpoint(org.apache.ode.bpel.epr.MutableEndpoint) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Example 3 with HTTPBinding

use of javax.wsdl.extensions.http.HTTPBinding in project carbon-business-process by wso2.

the class PeopleActivity method getSoapFactory.

public SOAPFactory getSoapFactory() throws FaultException {
    Binding binding = getBinding();
    ExtensibilityElement bindingType = SOAPHelper.getBindingExtension(binding);
    if (!(bindingType instanceof SOAPBinding || bindingType instanceof SOAP12Binding || bindingType instanceof HTTPBinding)) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service binding is not supported for service " + serviceName + " and port " + getServicePort());
    }
    if (bindingType instanceof SOAPBinding) {
        return OMAbstractFactory.getSOAP11Factory();
    } else {
        return OMAbstractFactory.getSOAP12Factory();
    }
}
Also used : HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) FaultException(org.apache.ode.bpel.common.FaultException) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding)

Example 4 with HTTPBinding

use of javax.wsdl.extensions.http.HTTPBinding in project teiid by teiid.

the class WSDLMetadataProcessor method extractExecutionBinding.

private WSExecutionFactory.Binding extractExecutionBinding(Binding binding) throws TranslatorException {
    WSExecutionFactory.Binding executionBinding = WSExecutionFactory.Binding.SOAP11;
    // $NON-NLS-1$
    ExtensibilityElement bindingExtension = getExtensibilityElement(binding.getExtensibilityElements(), "binding");
    if (bindingExtension instanceof SOAPBinding) {
        executionBinding = WSExecutionFactory.Binding.SOAP11;
    } else if (bindingExtension instanceof SOAP12Binding) {
        executionBinding = WSExecutionFactory.Binding.SOAP12;
    } else if (bindingExtension instanceof HTTPBinding) {
        executionBinding = WSExecutionFactory.Binding.HTTP;
    } else {
        throw new TranslatorException(WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15003));
    }
    return executionBinding;
}
Also used : SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) TranslatorException(org.teiid.translator.TranslatorException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding)

Example 5 with HTTPBinding

use of javax.wsdl.extensions.http.HTTPBinding in project wso2-synapse by wso2.

the class WSDL11EndpointBuilder method createEndpointDefinitionFromWSDL.

private EndpointDefinition createEndpointDefinitionFromWSDL(EndpointDefinition endpointDefinition, Definition definition, String serviceName, String portName) {
    if (definition == null) {
        handleException("WSDL document is not specified.");
    }
    if (serviceName == null) {
        handleException("Service name of the WSDL document is not specified.");
    }
    if (portName == null) {
        handleException("Port name of the WSDL document is not specified.");
    }
    String serviceURL = null;
    // get soap version from wsdl port and update endpoint definition below
    // so that correct soap version is used when endpoint is called
    String format = null;
    assert definition != null;
    String tns = definition.getTargetNamespace();
    Service service = definition.getService(new QName(tns, serviceName));
    if (service != null) {
        Port port = service.getPort(portName);
        if (port != null) {
            for (Object obj : port.getExtensibilityElements()) {
                if (obj instanceof SOAPAddress) {
                    SOAPAddress address = (SOAPAddress) obj;
                    serviceURL = address.getLocationURI();
                    format = SynapseConstants.FORMAT_SOAP11;
                    break;
                } else if (obj instanceof SOAP12Address) {
                    SOAP12Address address = (SOAP12Address) obj;
                    serviceURL = address.getLocationURI();
                    format = SynapseConstants.FORMAT_SOAP12;
                    break;
                } else if (obj instanceof HTTPAddress) {
                    HTTPAddress address = (HTTPAddress) obj;
                    serviceURL = address.getLocationURI();
                    format = SynapseConstants.FORMAT_REST;
                    Binding binding = port.getBinding();
                    if (binding == null) {
                        continue;
                    }
                    for (Object portElement : binding.getExtensibilityElements()) {
                        if (portElement instanceof HTTPBinding) {
                            HTTPBinding httpBinding = (HTTPBinding) portElement;
                            String verb = httpBinding.getVerb();
                            if (verb == null || "".equals(verb)) {
                                continue;
                            }
                            if ("POST".equals(verb.toUpperCase())) {
                                format = SynapseConstants.FORMAT_REST;
                            } else if ("GET".equals(verb.toUpperCase())) {
                                format = SynapseConstants.FORMAT_GET;
                            }
                        }
                    }
                }
            }
        }
    }
    if (serviceURL != null) {
        endpointDefinition.setAddress(serviceURL);
        if (SynapseConstants.FORMAT_SOAP11.equals(format)) {
            endpointDefinition.setForceSOAP11(true);
        } else if (SynapseConstants.FORMAT_SOAP12.equals(format)) {
            endpointDefinition.setForceSOAP12(true);
        } else if (SynapseConstants.FORMAT_REST.equals(format)) {
            endpointDefinition.setForceREST(true);
        } else if (SynapseConstants.FORMAT_GET.equals(format)) {
            endpointDefinition.setForceGET(true);
        } else {
            handleException("format value '" + format + "' not yet implemented");
        }
        endpointDefinition.setFormat(format);
        return endpointDefinition;
    } else {
        handleException("Couldn't retrieve endpoint information from the WSDL.");
    }
    return null;
}
Also used : HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) QName(javax.xml.namespace.QName) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding)

Aggregations

HTTPBinding (javax.wsdl.extensions.http.HTTPBinding)5 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)2 HashSet (java.util.HashSet)1 Binding (javax.wsdl.Binding)1 BindingOperation (javax.wsdl.BindingOperation)1 Operation (javax.wsdl.Operation)1 HTTPAddress (javax.wsdl.extensions.http.HTTPAddress)1 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)1 SOAP12Address (javax.wsdl.extensions.soap12.SOAP12Address)1 QName (javax.xml.namespace.QName)1 MessageContext (org.apache.axis2.context.MessageContext)1 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)1 FaultException (org.apache.ode.bpel.common.FaultException)1 MutableEndpoint (org.apache.ode.bpel.epr.MutableEndpoint)1 TranslatorException (org.teiid.translator.TranslatorException)1 WSDLOperation (org.wso2.carbon.apimgt.core.models.WSDLOperation)1