2
簡單問題:Get請求對象的webMethods Java服務
- 我有一個webMethods的 「REST服務」(彥博)。
- 在「REST服務」服務中,我稱自己寫的java服務。
- 在java服務裏面我想獲取請求的原始內容。
任何想法?
簡單問題:Get請求對象的webMethods Java服務
任何想法?
根據Content-Type
標題,webMethods選擇ContentHandler
來解析輸入。原體可以通過這樣的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