0

I have a very simple usecase which has worked previously. But in this new mpgw where flow is

url-open to an API & get json response & process that response before sending to client, it doesn't work.

I have tried the below in xslt

  <xsl:variable name="Response">
     <dp:url-open target="{$routing_URL}" response="responsecode-binary" http-method="get" ssl-proxy="client:mpgw_Client_SSL_Profile" timeout="'10'">
     </dp:url-open>
   </xsl:variable>

 <!-- Decoding the binary node so that it can be further used in the processing rules -->
   <xsl:variable name="json">
    <xsl:copy-of select="dp:decode(dp:binary-encode($Response/result/binary/node()), 'base-64' )" /> 
   </xsl:variable>

   <dp:set-variable name="'var://context/service_session/json'" value="string($json)" />
   <xsl:value-of select="$json"/>

I can see the context variable getting the json data. But when i use convert query param after this transform action it fails with below error:

Convert HTTP produced invalid XML: Incomplete markup or missing 
document element at offset 39 of ...

I have also tried using the context __JSONASJSONX in output of transform & input of next transform, but there also the data is not converted to JSONX.

I have read other forums where this error means data is empty but I can see the data in context variable.

Any idea what could go wrong here?

swetad90
  • 784
  • 1
  • 13
  • 34
  • If it is JSON, why are you not using GatewayScript? – Anders Oct 03 '18 at 15:29
  • __JSONASJSONX works only if the input of the mpgw INPUT is set to JSON... but the api call is *IN* your xslt code here, so the input to the mpgw is proabably not JSON. – GhislainCote Oct 05 '18 at 19:45
  • What is in the $Response/result/responsecode ? Does $Response/result/errorstatuscode and $Response/result/errorstring exist ? – GhislainCote Oct 05 '18 at 19:46
  • 3rd and final question, why do you use dp:decode and dp:binary-encode on the same variable ? They are basically opposites, are they not ? Should dp:decode be enough ? – GhislainCote Oct 05 '18 at 19:48

0 Answers0