Package org.switchyard.component.soap.composer

Examples of org.switchyard.component.soap.composer.SOAPBindingData


            // identify ourselves
            exchange.getContext().setProperty(ExchangeCompletionEvent.GATEWAY_NAME, _gatewayName, Scope.EXCHANGE)
                    .addLabels(BehaviorLabel.TRANSIENT.label());

            SOAPBindingData soapBindingData = new SOAPBindingData(soapMessage, wsContext);

            // add any thread-local and/or binding-extracted credentials
            SecurityContext securityContext = _securityContextManager.getContext(exchange);
            securityContext.getCredentials().addAll(credentials);
            securityContext.getCredentials().addAll(soapBindingData.extractCredentials());
            _securityContextManager.setContext(exchange, securityContext);

            Message message;
            try {
                message = _messageComposer.compose(soapBindingData, exchange);
View Full Code Here


            return handleException(oneWay, se);
        }
    }

    private SOAPMessage composeResponse(Exchange exchange, MessageContext msgContext, Operation operation, Boolean oneWay) throws SOAPException {
        SOAPBindingData bindingData = new SOAPBindingData(SOAPUtil.createMessage(_bindingId));
        SOAPMessage soapResponse;
        try {
            soapResponse = _messageComposer.decompose(exchange, bindingData).getSOAPMessage();
            if ((msgContext != null) && (bindingData.getStatus() != null)) {
                msgContext.put(MessageContext.HTTP_RESPONSE_CODE, bindingData.getStatus());
            }
        } catch (SOAPException soapEx) {
            throw soapEx;
        } catch (Exception ex) {
            // The map will contain the exception name only if WS-A is enabled, so no need to check if WS-A is enabled
View Full Code Here

            SOAPMessage request;
            Boolean oneWay = false;
            String action = null;
            try {
                request = _messageComposer.decompose(exchange, new SOAPBindingData(SOAPUtil.createMessage(_bindingId))).getSOAPMessage();

                QName firstBodyElement = SOAPUtil.getFirstBodyElement(request);
                action = WSDLUtil.getSoapAction(_wsdlPort, firstBodyElement, _documentStyle);
                oneWay = WSDLUtil.isOneWay(_wsdlPort, firstBodyElement, _documentStyle);

                if (_feature.isAddressingEnabled()) {
                    Context context = exchange.getContext();
                    _dispatcher.getRequestContext().put(SOAPUtil.SWITCHYARD_CONTEXT, context);
                    // It is a one way if a replyto address is set
                    String toAddress = SOAPUtil.getToAddress(exchange.getContext());
                    if (toAddress != null) {
                        _dispatcher.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, toAddress);
                    }
                }
            } catch (Exception e) {
                throw e instanceof SOAPException ? (SOAPException)e : new SOAPException(e);
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Outbound ---> Request:[" + _referenceName + "][" + SOAPUtil.soapMessageToString(request) + "]" + (oneWay ? " oneWay " : ""));
            }
            SOAPMessage response = invokeService(request, oneWay, action);
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Outbound <--- Response:[" + _referenceName + "][" + SOAPUtil.soapMessageToString(response) + "]");
            }
            if (response != null) {
                // This property vanishes once message composer processes this message
                // so caching it here
                Boolean hasFault = response.getSOAPBody().hasFault();
                Message message;
                try {
                    SOAPBindingData bindingData = new SOAPBindingData(response);
                    if (hasFault) {
                        SOAPFaultInfo faultInfo = new SOAPFaultInfo();
                        faultInfo.copyFaultInfo(response);
                        bindingData.setSOAPFaultInfo(faultInfo);
                    }
                    Integer status = (Integer)_dispatcher.getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE);
                    if (status != null) {
                        bindingData.setStatus(status);
                    }
                    message = _messageComposer.compose(bindingData, exchange);
                } catch (Exception e) {
                    throw e instanceof SOAPException ? (SOAPException)e : new SOAPException(e);
                }
View Full Code Here

        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(soapHeadersType);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("John", getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals("Doe", getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here

        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.XML);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("<first xmlns=\"urn:names:1.0\">John</first>", getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals("<last xmlns=\"urn:names:1.0\">Doe</last>", getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here

        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.CONFIG);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals(newConfiguration("<first xmlns=\"urn:names:1.0\">John</first>"), getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals(newConfiguration("<last xmlns=\"urn:names:1.0\">Doe</last>"), getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here

        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.DOM);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("<first xmlns=\"urn:names:1.0\">John</first>", toString((Element)getPropertyValue(targetContext, FIRST_NAME)));
        Assert.assertEquals("<last xmlns=\"urn:names:1.0\">Doe</last>", toString((Element)getPropertyValue(targetContext, LAST_NAME)));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMesssage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMesssage));
        Assert.assertEquals("John", getChildElement(targetMesssage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMesssage, LAST_NAME).getTextContent());
    }
View Full Code Here

TOP

Related Classes of org.switchyard.component.soap.composer.SOAPBindingData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.