Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get request object in webMethods Java service

Simple question:

  • I have a webMethods "REST-Service" (_post).
  • Inside the "REST-Service" service I call a self written java service.
  • Inside the java service I want to get the raw body of the request.

Any ideas?


1 Answers

Depending on the Content-Type header, webMethods chooses a ContentHandler to parse the inputs. The raw body can be preserved by such a ContentHandler, but it's not done in a uniform way.

example 1, for Content-Type: application/x-www-form-urlencoded:

InvokeState is = InvokeState.getCurrentState();
byte[] bytesIn = (byte[])is.getPrivateData("$msgBytesIn");
String body = null;
if (bytesIn!=null) {
    body = new String(bytesIn, StandardCharsets.UTF_8);
}
// body now contains the request body

example 2, for Content-Type: multipart/form-data:

IDataCursor pipelineCursor = pipeline.getCursor();
InputStream bodyStream = (InputStream)IDataUtil.get( pipelineCursor, "contentStream" );
pipelineCursor.destroy();
// bodyStream now contains the request body
like image 189
TijsH Avatar answered May 17 '26 12:05

TijsH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!