Skip to content

Commit 637cc80

Browse files
committed
refactor(soap): optimises document type lookup.
1 parent 59cc2dc commit 637cc80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class SoapExampleService {
127127
val elementSchema = SchemaGenerator.createCompositePartSchema(service.targetNamespace ?: "", rootElement, parts)
128128
val sts: SchemaTypeSystem = buildSchemaTypeSystem(schemaContext, elementSchema)
129129

130-
val elem = sts.documentTypes().find { it.documentElementName == rootElement }
130+
val elem = sts.findDocumentType(rootElement)
131131
?: throw RuntimeException("Could not find a generated element with name \"$rootElement\"")
132132

133133
return SampleXmlUtil.createSampleForType(elem)
@@ -167,7 +167,7 @@ class SoapExampleService {
167167
outputRef: ElementOperationMessage,
168168
): String {
169169
val rootElementName = outputRef.elementName
170-
val elem: SchemaType = schemaContext.sts.documentTypes().find { it.documentElementName == rootElementName }
170+
val elem: SchemaType = schemaContext.sts.findDocumentType(rootElementName)
171171
?: throw RuntimeException("Could not find a global element with name \"$rootElementName\"")
172172

173173
return SampleXmlUtil.createSampleForType(elem)
@@ -178,11 +178,11 @@ class SoapExampleService {
178178
service: WsdlService,
179179
message: TypeOperationMessage,
180180
): String {
181-
val elementName = message.partName
181+
val elementName = QName(service.targetNamespace, message.partName)
182182
val elementSchema = SchemaGenerator.createSinglePartSchema(service.targetNamespace ?: "", message)
183183
val sts: SchemaTypeSystem = buildSchemaTypeSystem(schemaContext, elementSchema)
184184

185-
val elem = sts.documentTypes().find { it.documentElementName.localPart == elementName }
185+
val elem = sts.findDocumentType(elementName)
186186
?: throw RuntimeException("Could not find a generated element with name \"$elementName\"")
187187

188188
return SampleXmlUtil.createSampleForType(elem)

0 commit comments

Comments
 (0)