question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Regex with XML in request.file and response.file

See original GitHub issue

We’re using Stubby4J to mock a SOAP API but we’re having issues extracting values from the request and injecting them into the response.

The stub config is similar to the following (removed project specific naming):

- request:
    method: POST
    url: /path/SomeService
    file: ./requests/ExpectedRequestFormat.xml
 
  response:
    status: 200
    headers:
      content-type: application/xml
    file: ./data/SomeServiceResponse.xml

In ExpectedRequestFormat.xml we have multiple instances of the following:

<ns:SomeElement>${xmlunit.matchesRegex(.*)}</ns:SomeElement>

And in SomeServiceResponse.xml we have:

<ns:SomeOtherElement><% file.1 %></ns:SomeOtherElement>

We have also tried the following:

<ns:SomeOtherElement><% post.1 %></ns:SomeOtherElement>
<ns:SomeOtherElement><% request.file.1 %></ns:SomeOtherElement>
<ns:SomeOtherElement><% request.post.1 %></ns:SomeOtherElement>

However the response is always the raw XML file with no injection of values.

Any ideas what we are doing wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
azagniotovcommented, Dec 18, 2021

@itsjxck, just FYI:

stubby4j Docker images that use log4j2 and that were affected as a result of recent log4j2 vulnerabilities: CVE-2021-44228 and CVE-2021-45046 (i.e.: latest and <= v7.5.0) have been re-built as part of the mitigation effort captured by the following ticket https://github.com/azagniotov/stubby4j/issues/416

1reaction
azagniotovcommented, Dec 10, 2021

@itsjxck , I pushed azagniotov/stubby4j:7.5.0-jre11, in case if you want to be fixed to a specific tag. It has all the behavior we tested, and some more (all of that was in the master already anyways): https://github.com/azagniotov/stubby4j/blob/master/docs/CHANGELOG.md#750

Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need Regex pattern to extract xml request and responses ...
I have a log file with multiple xml requests and responses. I need to parse each set request/responses. With my limited regex experience, ......
Read more >
Define regular expressions in XML files - IBM
You can define regular expressions for input validation in separate XML files. Reference to these regular expressions can be used in multiple data...
Read more >
Insert Lines after Multi-Line Regex Match - Unix Stack Exchange
The reason I need to do multiline matching is because the <dict> tag is used frequently within the XML file and I need...
Read more >
4. Pattern Matching with Regular Expressions - Java ... - O'Reilly
I used the pattern main(String [a-z] with the grep utility described earlier to find the names of all the files containing old-style main...
Read more >
Everything you need to know about Regular Expressions
After reading this article you will have a solid understanding of what regular expressions are, what they can do, and what they can't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found