Search in sources :

Example 1 with SoapRequestBuilder

use of org.mule.runtime.soap.api.message.SoapRequestBuilder in project mule by mulesoft.

the class SoapOperationExecutor method getRequest.

/**
 * Builds a Soap Request with the execution context to be sent using the {@link SoapClient}.
 */
private SoapRequest getRequest(ExecutionContext<OperationModel> context, Map<String, String> fixedHeaders) throws MessageTransformerException, TransformerException {
    SoapRequestBuilder builder = SoapRequest.builder().operation(getOperation(context));
    builder.soapHeaders(fixedHeaders);
    Optional<Object> optionalMessageGroup = getParam(context, MESSAGE_GROUP);
    if (optionalMessageGroup.isPresent()) {
        Map<String, Object> message = (Map<String, Object>) optionalMessageGroup.get();
        InputStream body = (InputStream) message.get(BODY_PARAM);
        if (body != null) {
            builder.content(body);
        }
        InputStream headers = (InputStream) message.get(HEADERS_PARAM);
        if (headers != null) {
            builder.soapHeaders((Map<String, String>) evaluateHeaders(headers));
        }
        Map<String, TypedValue<?>> attachments = (Map<String, TypedValue<?>>) message.get(ATTACHMENTS_PARAM);
        if (attachments != null) {
            toSoapAttachments(attachments).forEach(builder::attachment);
        }
    }
    getParam(context, TRANSPORT_HEADERS_PARAM).ifPresent(th -> builder.transportHeaders((Map<String, String>) th));
    return builder.build();
}
Also used : InputStream(java.io.InputStream) SoapRequestBuilder(org.mule.runtime.soap.api.message.SoapRequestBuilder) HashMap(java.util.HashMap) Map(java.util.Map) TypedValue(org.mule.runtime.api.metadata.TypedValue)

Aggregations

InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TypedValue (org.mule.runtime.api.metadata.TypedValue)1 SoapRequestBuilder (org.mule.runtime.soap.api.message.SoapRequestBuilder)1