Skip to content
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

SOAP : WSDL with includes fails parsing #548

Closed
driesva opened this issue Apr 11, 2024 · 1 comment · Fixed by #549
Closed

SOAP : WSDL with includes fails parsing #548

driesva opened this issue Apr 11, 2024 · 1 comment · Fixed by #549

Comments

@driesva
Copy link
Contributor

driesva commented Apr 11, 2024

We have been provided a large set of WSDLs as an artifact. These WSDLs are including their schemas through xs:include using a relative path. Schemas are also located in a hierarchical structure.

When configuring such a WSDL in Imposter, we encounter a Schema compilation error.
In the end it turns out to be an XmlBeans error:
Caused by: org.apache.xmlbeans.XmlException: error: Could not load resource "schema-include.xsd" (network downloads disabled).

I found issue https://issues.apache.org/jira/browse/XMLBEANS-479 but when enabling downloads (using XmlOptions().setCompileDownloadUrls()) other issues appear (with existing tests):
Caused by: org.apache.xmlbeans.XmlException: error: URL "schema.xsd" is not well-formed
(Error is also mentioned in comments of that XmlBeans issue, however issue is resolved...)

A quick solution I've found was to provide a custom entity resolver using
XmlOptions().setEntityResolver(...). That entity resolver will look for XML schemas relative to the configured WSDL.

This worked for the parsing part. However the same problem appears when generating sample responses in SoapExampleService by calling XmlBean's SchemaInstanceGenerator. The latter does not let you configure XmlOptions directly.

Therefore the alternative I found was to configure this entity resolver globally. This was however a challenge on its own as the resolver needs the WSDL path, which is config specific. Given multiple threads are being used, I opted for a ThreadLocal.

I'll provide a PR with these changes.

driesva added a commit to driesva/imposter that referenced this issue Apr 11, 2024
Currently, WSDLs with xs:include fail parsing.
This fix configures XMLBeans to look for XML schemas which are include/imported relative to the folder having the configured WSDL.

fixes outofcoffee#548
outofcoffee pushed a commit that referenced this issue Apr 15, 2024
Currently, WSDLs with xs:include fail parsing.
This fix configures XMLBeans to look for XML schemas which are include/imported relative to the folder having the configured WSDL.

fixes #548
@outofcoffee
Copy link
Owner

Thank you very much for your work on this @driesva.

Released in v3.36.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants