使用 Apama HTTP 客户端插件解析 HTTP 响应时出错

Error Parsing HTTP Response Using Apama HTTP Client plugin

我正在尝试使用 Apama HTTP 客户端插件对 REST API 进行 HTTP 调用。我能够向 REST 资源发送请求,但在解析响应时,出现以下错误。

WARN  [20176] - Failed to parse the event "`{contentType:application/json,sag.type:apamax.httpserversample.HTTPResponse,http:{headers:{contentLength:50,content-type:application/json,content-length:50},statusCode:200,method:POST,path:/rest/POC_422837/WS/provider/apamaTestConn,cookies:{},statusReason:OK}}{body:{status:Hello Apama. How are you doing?}}" 
   from httpClient due to the error: Unable to parse event apamax.httpserversample.HTTPResponse: 
   Unable to parse string from the map '{status:Hello Apama. How are you doing?}': 
   Invalid datatype, could not cast to string` 

YAML 配置文件如下所示,

connectivityPlugins:
  HTTPClientGenericTransport:
    libraryName: connectivity-http-client
    class: HTTPClient

startChains:
  httpClient:
    - apama.eventMap
    - mapperCodec:
        apamax.httpserversample.HTTPRequest:
          towardsTransport:
            mapFrom:
              - metadata.http.path: payload.path
              - metadata.requestId: payload.id
              - metadata.http.method: payload.method
              - payload: payload.data
            defaultValue:
              - metadata.contentType: application/json
              - metadata.sag.type: HelloWorld
        apamax.httpserversample.HTTPResponse:
          towardsHost:
            mapFrom:
              - payload.body: payload
              - payload.id: metadata.requestId
        apamax.httpserversample.HTTPError:
          towardsHost:
            mapFrom:
              - payload.id: metadata.requestId
              - payload.code: metadata.http.statusCode
              - payload.message: metadata.http.statusReason
    - classifierCodec:
        rules:
          - apamax.httpserversample.HTTPResponse:
            - metadata.http.statusCode: 200
          - apamax.httpserversample.HTTPError:
            - metadata.http.statusCode:
    - jsonCodec:
        filterOnContentType: true
    - stringCodec
    - HTTPClientGenericTransport:
        host: ${CORRELATOR_HOST}
        port: ${CORRELATOR_PORT}

请帮忙。

我认为问题在于您在配置中映射

    apamax.httpserversample.HTTPResponse:
      towardsHost:
        mapFrom:
          - payload.body: payload
          - payload.id: metadata.requestId

对 HTTPResponse.body 的响应的有效负载。

但是从warning可以看出,payload其实是一张地图,所以你需要做

- payload.body: payload.status