imposter icon indicating copy to clipboard operation
imposter copied to clipboard

[BUG] [SOAP plugin] java.lang.NullPointerException: null

Open s33kers opened this issue 2 years ago • 2 comments

Pre conditions

  • WSDL is correct and works fine with other tools (e.g. Soap UI), mock server can be created with Soap UI
  • WSDL and XSD are within same file, without imports to external file

Configuration

docker-compose.yaml

version: '3'

services:
  imposter:
    image: outofcoffee/imposter-all
    ports:
      - 8443:8443
    volumes:
      - $PWD:/opt/imposter/config

XXX-config.yaml

plugin: soap
wsdlFile: XXX.wsdl

Error

mockserver-imposter-1  | 13:34:10 INFO  i.g.i.Imposter - Starting mock engine 3.0.0
mockserver-imposter-1  | 13:34:10 DEBUG i.g.i.c.u.ConfigUtil - Loading configuration file: /opt/imposter/config/XXX-config.yaml
mockserver-imposter-1  | 13:34:11 DEBUG i.g.i.p.PluginManager - Loaded 8 plugin(s): [js-detector, store-detector, meta-detector, js-nashorn-standalone, store-inmem, config-detector, store-graphql, soap]
mockserver-imposter-1  | 13:34:11 DEBUG i.g.i.p.s.p.VersionAwareWsdlParser - Using WSDL parser: V1 for: /opt/imposter/config/XXX.wsdl
mockserver-imposter-1  | 13:34:12 DEBUG i.g.i.p.s.p.Wsdl1Parser - Resolved element name tns:Close to qualified type: null
mockserver-imposter-1  | 13:34:12 ERROR i.v.c.i.l.c.VertxIsolatedDeployer - Failed in deploying verticle
mockserver-imposter-1  | java.lang.NullPointerException: null
mockserver-imposter-1  | 	at io.gatehill.imposter.plugin.soap.parser.Wsdl1Parser.getOperation(Wsdl1Parser.kt:159) ~[imposter-mock-soap-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.plugin.soap.parser.Wsdl1Parser.getBinding(Wsdl1Parser.kt:89) ~[imposter-mock-soap-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.plugin.soap.parser.VersionAwareWsdlParser.getBinding(VersionAwareWsdlParser.kt:91) ~[imposter-mock-soap-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.plugin.soap.SoapPluginImpl.parseWsdls(SoapPluginImpl.kt:122) ~[imposter-mock-soap-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.plugin.soap.SoapPluginImpl.configureRoutes(SoapPluginImpl.kt:106) ~[imposter-mock-soap-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.Imposter.configureRoutes(Imposter.kt:205) ~[imposter-engine-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.Imposter.access$configureRoutes(Imposter.kt:85) ~[imposter-engine-3.0.0.jar:?]
mockserver-imposter-1  | 	at io.gatehill.imposter.Imposter$start$1.invokeSuspend(Imposter.kt:128) ~[imposter-engine-3.0.0.jar:?]
mockserver-imposter-1  | 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.6.21.jar:1.6.21-release-334(1.6.21)]
mockserver-imposter-1  | 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.2.jar:?]
mockserver-imposter-1  | 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) ~[kotlinx-coroutines-core-jvm-1.6.2.jar:?]
mockserver-imposter-1  | 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) ~[kotlinx-coroutines-core-jvm-1.6.2.jar:?]
mockserver-imposter-1  | 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) ~[kotlinx-coroutines-core-jvm-1.6.2.jar:?]
mockserver-imposter-1  | 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ~[kotlinx-coroutines-core-jvm-1.6.2.jar:?]
mockserver-imposter-1 exited with code 0

s33kers avatar Jun 23 '22 13:06 s33kers

Hi @s33kers - thank you for reporting this.

The WSDL parser supports embedded schemas, as well as those referenced in external XSDs, so there appears to be a resolution problem here when looking up the element for the input message.

To help diagnose and fix this, please could you provide a sample WSDL file that exhibits this bug?

In addition, setting the following environment variable in your Docker Compose file will help provide more detailed logs:

IMPOSTER_LOG_LEVEL=TRACE

For example:

version: '3'

services:
  imposter:
    image: outofcoffee/imposter-all
    ports:
      - 8443:8443
    volumes:
      - $PWD:/opt/imposter/config
    environment:
      - IMPOSTER_LOG_LEVEL=TRACE

outofcoffee avatar Jun 27 '22 23:06 outofcoffee

Hi,

I ran Wsdl1ParserTest with my WSDL and found these problems (tried to modify WSDL without changing code to indetify problems)

  1. AbstractWsdlParser:76 supports extracting only 1 schema within WSDL. Workaround - extracted all schemas to separate .xsd
  2. Wsdl1Parser:165 style attribute is taken from operation, however it can be provided as binding as a default for all operations. Workaround - add style attribute to <soap:operation style="document" ... (e.g. https://schemas.xmlsoap.org/wsdl/soap12/soap12wsdl.htm see <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />)
  3. Wsdl1Parser:191 should use message attribute instead of name + remove schema prefix

Hope it helps someone too:)

s33kers avatar Jun 29 '22 05:06 s33kers

Support for multiple schemas in a WSDL file added in 44950332.

outofcoffee avatar Dec 08 '22 00:12 outofcoffee

Operation style fallback to binding style added in 765f1792.

outofcoffee avatar Dec 08 '22 01:12 outofcoffee

Use of message attribute to locate message element added in 39a9de05.

outofcoffee avatar Dec 08 '22 01:12 outofcoffee

Released in v3.3.0. Thanks again @s33kers.

outofcoffee avatar Dec 08 '22 01:12 outofcoffee