Skip to content

feature/707: improve soap 1.1 capture of proxy request/responses #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Main-Class: io.gatehill.imposter.cmd.ImposterLauncher
Imposter-Version: 0.0.0-SNAPSHOT
Multi-Release: true

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ class ImposterLauncher(args: Array<String>) {

@Option(name = "--serverFactory", usage = "Fully qualified class for server factory")
private var serverFactory: String = VertxWebServerFactoryImpl::class.java.canonicalName

@Option(name = "--soap", usage = "Enable SOAP-aware mode for capturing requests/responses with SOAPAction")
private var soapMode: Boolean = false

companion object {
private val LOGGER = LogManager.getLogger(ImposterLauncher::class.java)
Expand Down Expand Up @@ -204,6 +207,11 @@ class ImposterLauncher(args: Array<String>) {
imposterConfig.configDirs = configDirs
imposterConfig.plugins = plugins
imposterConfig.pluginArgs = splitArgs
imposterConfig.soapMode = soapMode

if (soapMode) {
LOGGER.info("SOAP-aware mode enabled - requests and responses will be saved with SOAPAction-based filenames")
}
}

LifecycleAwareLauncher().dispatch(originalArgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class ImposterConfig {
var pluginDiscoveryStrategy: PluginDiscoveryStrategy? = null
var pluginDiscoveryStrategyClass: String? = null
var useEmbeddedScriptEngine: Boolean = false
var soapMode: Boolean = false

override fun toString(): String {
return "ImposterConfig(host=$host, listenPort=$listenPort, configDirs=${configDirs.contentToString()}, serverUrl=$serverUrl, isTlsEnabled=$isTlsEnabled, keystorePath=$keystorePath, keystorePassword=$keystorePassword, plugins=${plugins?.contentToString()}, pluginArgs=$pluginArgs, serverFactory=$serverFactory, pluginDiscoveryStrategy=$pluginDiscoveryStrategy, pluginDiscoveryStrategyClass=$pluginDiscoveryStrategyClass, useEmbeddedScriptEngine=$useEmbeddedScriptEngine)"
return "ImposterConfig(host=$host, listenPort=$listenPort, configDirs=${configDirs.contentToString()}, serverUrl=$serverUrl, isTlsEnabled=$isTlsEnabled, keystorePath=$keystorePath, keystorePassword=$keystorePassword, plugins=${plugins?.contentToString()}, pluginArgs=$pluginArgs, serverFactory=$serverFactory, pluginDiscoveryStrategy=$pluginDiscoveryStrategy, pluginDiscoveryStrategyClass=$pluginDiscoveryStrategyClass, useEmbeddedScriptEngine=$useEmbeddedScriptEngine, soapMode=$soapMode)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import io.gatehill.imposter.service.ResponseService
import io.gatehill.imposter.service.ResponseServiceImpl
import io.gatehill.imposter.service.ScriptedResponseService
import io.gatehill.imposter.service.SecurityService
import io.gatehill.imposter.service.SoapAwareUpstreamService
import io.gatehill.imposter.service.StepService
import io.gatehill.imposter.service.UpstreamService
import io.gatehill.imposter.service.script.EmbeddedScriptService
Expand Down Expand Up @@ -99,5 +100,6 @@ internal class EngineModule : AbstractModule() {
bind(RemoteService::class.java).asSingleton()
bind(StepService::class.java).asSingleton()
bind(UpstreamService::class.java).asSingleton()
bind(SoapAwareUpstreamService::class.java).asSingleton()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class HandlerServiceImpl @Inject constructor(
private val interceptorService: InterceptorService,
private val responseService: ResponseService,
private val upstreamService: UpstreamService,
private val soapAwareUpstreamService: SoapAwareUpstreamService,
private val imposterConfig: ImposterConfig,
) : HandlerService, CoroutineScope by supervisedDefaultCoroutineScope {

private val shouldAddEngineResponseHeaders: Boolean =
Expand Down Expand Up @@ -339,11 +341,23 @@ class HandlerServiceImpl @Inject constructor(
pluginConfig: PluginConfig,
resourceConfig: BasicResourceConfig,
httpExchange: HttpExchange,
) = upstreamService.forwardToUpstream(
pluginConfig as UpstreamsHolder,
resourceConfig as PassthroughResourceConfig,
httpExchange
)
) = if (imposterConfig.soapMode) {
// Use SOAP-aware upstream service if SOAP mode is enabled
soapAwareUpstreamService.forwardToUpstream(
pluginConfig as UpstreamsHolder,
resourceConfig as PassthroughResourceConfig,
httpExchange,
imposterConfig.configDirs.firstOrNull() ?: ".",
imposterConfig.soapMode
)
} else {
// Use standard upstream service
upstreamService.forwardToUpstream(
pluginConfig as UpstreamsHolder,
resourceConfig as PassthroughResourceConfig,
httpExchange
)
}

companion object {
private val LOGGER = LogManager.getLogger(HandlerServiceImpl::class.java)
Expand Down
Loading