在 webMethods Java 服务中获取请求对象

Get request object in webMethods Java service

简单问题:

有什么想法吗?

根据 Content-Type header,webMethods 选择 ContentHandler 来解析输入。原始的body可以通过这样的ContentHandler来保存,但不是以统一的方式完成的。

示例 1,对于 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

示例 2,对于 Content-Type: multipart/form-data:

IDataCursor pipelineCursor = pipeline.getCursor();
InputStream bodyStream = (InputStream)IDataUtil.get( pipelineCursor, "contentStream" );
pipelineCursor.destroy();
// bodyStream now contains the request body