2015-11-05 127 views

回答

2

根據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