Package org.opensaml.soap.client.soap11.encoder.http.impl

# Class HttpClientRequestSOAP11Encoder

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.encoder.AbstractMessageEncoder
org.opensaml.messaging.encoder.httpclient.AbstractHttpClientRequestMessageEncoder
org.opensaml.messaging.encoder.httpclient.BaseHttpClientRequestXMLMessageEncoder
org.opensaml.soap.client.soap11.encoder.http.impl.HttpClientRequestSOAP11Encoder

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `UnmodifiableComponent`, `HttpClientRequestMessageEncoder`, `MessageEncoder`

Direct Known Subclasses:
  `HttpClientRequestSOAP11Encoder`, `HttpClientRequestSOAP11Encoder`

public class HttpClientRequestSOAP11Encoder extends BaseHttpClientRequestXMLMessageEncoder
Basic SOAP 1.1 encoder for HTTP transport via an HttpClient's `ClassicHttpRequest`.

## Field Summary

Fields
Modifier and Type
Field
Description
`private SOAPObjectBuilder<Body>`
`bodyBuilder`
SOAP Body builder.
`private SOAPObjectBuilder<Envelope>`
`envBuilder`
SOAP Envelope builder.
`private final org.slf4j.Logger`
`log`
Class logger.

### Fields inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder

`BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY`

## Constructor Summary

Constructors
Constructor
Description
`HttpClientRequestSOAP11Encoder()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`buildAndStoreSOAPMessage(XMLObject payload)`
Builds the SOAP message to be encoded.
`protected org.apache.hc.core5.http.HttpEntity`
`createRequestEntity(Envelope message, Charset charset)`
Create the request entity that makes up the POST message body.
`protected void`
`doEncode()`
Performs the encoding logic.
`org.apache.hc.client5.http.classic.methods.HttpPost`
`getHttpRequest()`
Get the HTTP client request on which to operate.
`protected XMLObject`
`getMessageToLog()`
Get the XMLObject which will be logged as the protocol message.
`protected String`
`getSOAPAction()`
Determine the value of the SOAPAction HTTP header to send.
`protected Envelope`
`getSOAPEnvelope()`
Retrieve the previously stored SOAP envelope from the message context.
`void`
`prepareContext()`
This method should prepare the message context by creating and populating any binding-specific data structures required in the MessageContext, prior to actually encoding.
`protected void`
`prepareHttpRequest()`
This implementation performs the following actions on the context's `ClassicHttpRequest`:
`void`
`setHttpRequest(org.apache.hc.core5.http.ClassicHttpRequest httpRequest)`
Set the HTTP client request on which to operate.
`protected void`
`storeSOAPEnvelope(Envelope envelope)`
Store the constructed SOAP envelope in the message context for later encoding.

### Methods inherited from class org.opensaml.messaging.encoder.httpclient.BaseHttpClientRequestXMLMessageEncoder

`encode, marshallMessage, serializeMessageForLogging`

### Methods inherited from class org.opensaml.messaging.encoder.httpclient.AbstractHttpClientRequestMessageEncoder

`doInitialize`

### Methods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder

`getMessageContext, getProtocolMessageLogger, getProtocolMessageLoggerSubCategory, logEncodedMessage, setMessageContext, setProtocolMessageLoggerSubCategory`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

`destroy, isDestroyed`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

### Methods inherited from interface org.opensaml.messaging.encoder.MessageEncoder

`setMessageContext`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### envBuilder

@Nonnull private SOAPObjectBuilder<Envelope> envBuilder
SOAP Envelope builder.

### bodyBuilder

@Nonnull private SOAPObjectBuilder<Body> bodyBuilder
SOAP Body builder.

## Constructor Details

### HttpClientRequestSOAP11Encoder

public HttpClientRequestSOAP11Encoder()
Constructor.

## Method Details

### getHttpRequest

@NonnullAfterInit public org.apache.hc.client5.http.classic.methods.HttpPost getHttpRequest()
Get the HTTP client request on which to operate.

This encoder implementation only operates on instances of `HttpPost`.

Specified by:
  `getHttpRequest` in interface `HttpClientRequestMessageEncoder`
Overrides:
  `getHttpRequest` in class `AbstractHttpClientRequestMessageEncoder`
Returns:
  the HTTP client request

### setHttpRequest

public void setHttpRequest(@Nullable org.apache.hc.core5.http.ClassicHttpRequest httpRequest)
Set the HTTP client request on which to operate.

This encoder implementation only operates on instances of `HttpPost`.

Specified by:
  `setHttpRequest` in interface `HttpClientRequestMessageEncoder`
Overrides:
  `setHttpRequest` in class `AbstractHttpClientRequestMessageEncoder`
Parameters:
  `httpRequest` - the HTTP client request

### prepareContext

public void prepareContext() throws MessageEncodingException
This method should prepare the message context by creating and populating any binding-specific data structures required in the MessageContext, prior to actually encoding.

This method should be called after the MessageContext has been set, and before any binding-specific Handler or HandlerChains are invoked.

Example: For a SOAP encoder, this method would create and store the basic SOAP Envelope structure in the message context, so that Handlers that are invoked have a place to which to add headers.

This method may be a no-op if not required by the binding, or if the message type of the context implies that the binding-specific structures have already been created elsewhere (e.g. message-oriented code where the calling code already knows its SOAP, and is operating on the raw SOAP envelope anyway).

. Default implementation is a no-op.

Specified by:
  `prepareContext` in interface `MessageEncoder`
Overrides:
  `prepareContext` in class `AbstractMessageEncoder`
Throws:
  `MessageEncodingException` - if there is a problem preparing the message context for encoding

### doEncode

protected void doEncode() throws MessageEncodingException
Performs the encoding logic. By the time this is called, this encoder has already been initialized and checked to ensure that it has not been destroyed.

Specified by:
  `doEncode` in class `AbstractMessageEncoder`
Throws:
  `MessageEncodingException` - thrown if there is a problem encoding the message

### createRequestEntity

protected org.apache.hc.core5.http.HttpEntity createRequestEntity(@Nonnull Envelope message, @Nonnull Charset charset) throws MessageEncodingException
Create the request entity that makes up the POST message body.

Parameters:
  `message` - message to be sent
  `charset` - character set used for the message
Returns:
  request entity that makes up the POST message body
Throws:
  `MessageEncodingException` - thrown if the message could not be marshalled

### storeSOAPEnvelope

protected void storeSOAPEnvelope(@Nullable Envelope envelope)
Store the constructed SOAP envelope in the message context for later encoding.

Parameters:
  `envelope` - the SOAP envelope

### getSOAPEnvelope

@Nullable protected Envelope getSOAPEnvelope()
Retrieve the previously stored SOAP envelope from the message context.

Returns:
  the previously stored SOAP envelope

### buildAndStoreSOAPMessage

protected void buildAndStoreSOAPMessage(@Nonnull XMLObject payload)
Builds the SOAP message to be encoded.

Parameters:
  `payload` - body of the SOAP message

### prepareHttpRequest

protected void prepareHttpRequest() throws MessageEncodingException

This implementation performs the following actions on the context's `ClassicHttpRequest`:

1. Sets the SOAPAction HTTP header the value returned by `getSOAPAction()`, if that returns non-null.

Subclasses should NOT set the SOAPAction HTTP header in this method. Instead, they should override the method `getSOAPAction()`.

Throws:
  `MessageEncodingException` - thrown if there is a problem preprocessing the transport

### getSOAPAction

@Nullable protected String getSOAPAction()
Determine the value of the SOAPAction HTTP header to send.

The default behavior is to return the value of the SOAP Envelope's WS-Addressing Action header, if present.

Returns:
  a SOAPAction HTTP header URI value

### getMessageToLog

@Nullable protected XMLObject getMessageToLog()
Get the XMLObject which will be logged as the protocol message.

Overrides:
  `getMessageToLog` in class `AbstractMessageEncoder`
Returns:
  the XMLObject message considered to be the protocol message for logging purposes