2015-11-05 112 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