Get请求对象的webMethods Java服务

Get请求对象的webMethods Java服务

问题描述:

简单问题:Get请求对象的webMethods Java服务

  • 我有一个webMethods的 “REST服务”(彦博)。
  • 在“REST服务”服务中,我称自己写的java服务。
  • 在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