Skip to content

Commit e6368f9

Browse files
committed
feat(soap): working support for WSDL 1.1 messages specifying type not element.
1 parent 4ac12e7 commit e6368f9

File tree

18 files changed

+112
-17
lines changed

18 files changed

+112
-17
lines changed

mock/soap/src/main/java/io/gatehill/imposter/plugin/soap/SoapResourceMatcher.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import io.gatehill.imposter.plugin.soap.config.SoapPluginResourceConfig
5454
import io.gatehill.imposter.plugin.soap.model.BindingType
5555
import io.gatehill.imposter.plugin.soap.model.ElementOperationMessage
5656
import io.gatehill.imposter.plugin.soap.model.MessageBodyHolder
57+
import io.gatehill.imposter.plugin.soap.model.TypeOperationMessage
5758
import io.gatehill.imposter.plugin.soap.model.WsdlBinding
5859
import io.gatehill.imposter.plugin.soap.model.WsdlOperation
5960
import io.gatehill.imposter.plugin.soap.util.SoapUtil
@@ -202,9 +203,17 @@ class SoapResourceMatcher(
202203
}
203204

204205
val matchedOps = binding.operations.filter { op ->
205-
op.inputRef is ElementOperationMessage &&
206-
op.inputRef.elementName.namespaceURI == bodyRootElement.namespaceURI &&
207-
op.inputRef.elementName.localPart == bodyRootElement.name
206+
when (op.inputRef) {
207+
is ElementOperationMessage -> {
208+
op.inputRef.elementName.namespaceURI == bodyRootElement.namespaceURI &&
209+
op.inputRef.elementName.localPart == bodyRootElement.name
210+
}
211+
is TypeOperationMessage -> {
212+
op.inputRef.typeName.namespaceURI == bodyRootElement.namespaceURI &&
213+
op.inputRef.operationName == bodyRootElement.name
214+
}
215+
else -> false
216+
}
208217
}
209218
if (LOGGER.isTraceEnabled) {
210219
LOGGER.trace(

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/AbstractEndToEndTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ abstract class AbstractEndToEndTest : BaseVerticleTest() {
6565
protected abstract val soapEnvNamespace: Namespace
6666
protected abstract val soapContentType: String
6767

68-
private val getPetByIdEnv
68+
protected open val getPetByIdEnv
6969
get() = SoapUtil.wrapInEnv(
7070
"""
7171
<getPetByIdRequest xmlns="urn:com:example:petstore">
@@ -74,7 +74,7 @@ abstract class AbstractEndToEndTest : BaseVerticleTest() {
7474
""".trim(), soapEnvNamespace
7575
)
7676

77-
private val getPetByNameEnv
77+
protected open val getPetByNameEnv
7878
get() = SoapUtil.wrapInEnv(
7979
"""
8080
<getPetByNameRequest xmlns="urn:com:example:petstore">

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/JAXWSTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import org.junit.Test
5858
*/
5959
class JAXWSTest : BaseVerticleTest() {
6060
override val pluginClass = SoapPluginImpl::class.java
61-
override val testConfigDirs = listOf("/wsdl1-soap11")
61+
override val testConfigDirs = listOf("/wsdl1-soap11-document")
6262

6363
private lateinit var baseURI: String
6464

@@ -71,7 +71,7 @@ class JAXWSTest : BaseVerticleTest() {
7171

7272
@Test
7373
fun testRequestResponseUsingSoapClient() {
74-
val wsdlUrl = JAXWSTest::class.java.getResource("/wsdl1-soap11/service.wsdl")
74+
val wsdlUrl = JAXWSTest::class.java.getResource("/wsdl1-soap11-document/service.wsdl")
7575
val soapEndpoint = PetService(wsdlUrl).soapEndpoint
7676

7777
(soapEndpoint as BindingProvider)

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/Wsdl1Soap11EndToEndTest.kt renamed to mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/Wsdl1Soap11DocumentEndToEndTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ import org.junit.Test
5050
*
5151
* @author Pete Cornish
5252
*/
53-
class Wsdl1Soap11EndToEndTest : AbstractEndToEndTest() {
54-
override val testConfigDirs = listOf("/wsdl1-soap11")
53+
class Wsdl1Soap11DocumentEndToEndTest : AbstractEndToEndTest() {
54+
override val testConfigDirs = listOf("/wsdl1-soap11-document")
5555
override val soapEnvNamespace = SoapUtil.soap11EnvNamespace
5656
override val soapContentType = SoapUtil.soap11ContentType
5757

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/Wsdl1Soap11MessageTypeEndToEndTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
package io.gatehill.imposter.plugin.soap
4444

4545
import io.gatehill.imposter.plugin.soap.util.SoapUtil
46+
import org.junit.Test
4647

4748
/**
4849
* Tests for [SoapPluginImpl] using WSDL v1 and SOAP 1.1.
@@ -53,4 +54,25 @@ class Wsdl1Soap11MessageTypeEndToEndTest : AbstractEndToEndTest() {
5354
override val testConfigDirs = listOf("/wsdl1-soap11-message-type")
5455
override val soapEnvNamespace = SoapUtil.soap11EnvNamespace
5556
override val soapContentType = SoapUtil.soap11ContentType
57+
58+
override val getPetByIdEnv: String
59+
get() = SoapUtil.wrapInEnv(
60+
"""
61+
<getPetById xmlns="urn:com:example:petstore">
62+
<id>3</id>
63+
</getPetById>
64+
""".trim(), soapEnvNamespace
65+
)
66+
67+
override val getPetByNameEnv
68+
get() = SoapUtil.wrapInEnv(
69+
"""
70+
<getPetByName xmlns="urn:com:example:petstore">
71+
<name>Fluffy</name>
72+
</getPetByName>
73+
""".trim(), soapEnvNamespace
74+
)
75+
76+
@Test
77+
fun testHttpBinding() = httpBinding()
5678
}

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/Wsdl1Soap11RpcEndToEndTest.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2021.
2+
* Copyright (c) 2016-2024.
33
*
44
* This file is part of Imposter.
55
*
@@ -53,4 +53,22 @@ class Wsdl1Soap11RpcEndToEndTest : AbstractEndToEndTest() {
5353
override val testConfigDirs = listOf("/wsdl1-soap11-rpc")
5454
override val soapEnvNamespace = SoapUtil.soap11EnvNamespace
5555
override val soapContentType = SoapUtil.soap11ContentType
56+
57+
override val getPetByIdEnv: String
58+
get() = SoapUtil.wrapInEnv(
59+
"""
60+
<getPetById xmlns="urn:com:example:petstore">
61+
<id>3</id>
62+
</getPetById>
63+
""".trim(), soapEnvNamespace
64+
)
65+
66+
override val getPetByNameEnv
67+
get() = SoapUtil.wrapInEnv(
68+
"""
69+
<getPetByName xmlns="urn:com:example:petstore">
70+
<name>Fluffy</name>
71+
</getPetByName>
72+
""".trim(), soapEnvNamespace
73+
)
5674
}

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/parser/VersionAwareWsdlParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import java.io.File
5555
class VersionAwareWsdlParserTest {
5656
@Test
5757
fun parseV1() {
58-
val wsdlFile = File(VersionAwareWsdlParserTest::class.java.getResource("/wsdl1-soap11/service.wsdl")!!.toURI())
58+
val wsdlFile = File(VersionAwareWsdlParserTest::class.java.getResource("/wsdl1-soap11-document/service.wsdl")!!.toURI())
5959
val parser = VersionAwareWsdlParser(wsdlFile)
6060

6161
assertEquals(WsdlParser.WsdlVersion.V1, parser.version)

mock/soap/src/test/java/io/gatehill/imposter/plugin/soap/parser/Wsdl1Soap11ParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Wsdl1Soap11ParserTest {
6363

6464
@Before
6565
fun setUp() {
66-
val wsdlFile = File(Wsdl1Soap11ParserTest::class.java.getResource("/wsdl1-soap11/service.wsdl")!!.toURI())
66+
val wsdlFile = File(Wsdl1Soap11ParserTest::class.java.getResource("/wsdl1-soap11-document/service.wsdl")!!.toURI())
6767
val document = SAXBuilder().build(wsdlFile)
6868
val entityResolver = WsdlRelativeXsdEntityResolver(wsdlFile.parentFile)
6969
parser = Wsdl1Parser(wsdlFile, document, entityResolver)

0 commit comments

Comments
 (0)