Skip to content

Commit

Permalink
Custom Column for SOAPMethods
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoblentz committed Apr 16, 2024
1 parent 5230568 commit 340eb35
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CustomColumn/Proxy/HTTP/SOAPMethod.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Extracts the Method and an example value from a SOAP Request
* @author Nick Coblentz (https://github.com/ncoblentz)
*
* Currently extracts the soap method and the WS-Security Username field's value.
* Assumes the body tag's namespace is "s" as in `<s:Body`, customize if your SOAP request tags don't match
* Customize by adding additional RegEx's to extract more content
**/

if(requestResponse.request().hasHeader("Content-Type")
&& requestResponse.request().headerValue("Content-Type").contains("soap+xml"))
{
StringBuilder builder = new StringBuilder();
if(requestResponse.request().bodyToString().contains("<s:Body"))
{
Matcher m = Pattern.compile("<(?:[a-zA-Z0-9]+:)?Username>([^<]+)</(?:[a-zA-Z0-9]+:)*Username>|<(?:[a-zA-Z0-9]+:)*Body[^>]*><([^ ]+)",Pattern.CASE_INSENSITIVE).matcher(requestResponse.request().bodyToString());
while(m.find() && m.groupCount()>0) {
for(int i=1;i<=m.groupCount();i++) {
if(m.group(i)!=null)
builder.append(m.group(i)+" ");
}
}
return builder.toString();
}
}
return "";

0 comments on commit 340eb35

Please sign in to comment.