title: WSO2 EI - RelayUtils Error while building Passthrough stream
body: <p>I'm using WSO2 EI 6.3.0 and i want to get data from specific webservice and push this data to an other webservice.</p>
  
  <p>In the first time, i have to get the JWT Token from a first webservice to put it in the second call to get data.</p>
  
  <p>So, i created several sequence to have reusable sequences.
  I have the error when i want to inject bearer token header into my endpoint to get data. </p>
  
  <p>STEP OF IN SEQUENCE</p>
  
  <ul>
  <li><p>During the LogincheckSeq, i call the login_check api to get the JWT Token. </p></li>
  <li><p>Then during the createBearerTokenSeq, i only create a property with the token recovered from LoginCheckSeq   </p></li>
  <li><p>Then we pass in the CreateBearerTokenSeq, to create a property with the token recovered before from the json response of the LoginCheckEP</p></li>
  <li><p>Finally, we pass in the last sequence GetCustomerSeq to get customers informations from the webservice in json thanks to the jwt token given in the header (Authorization: Bearer token)</p></li>
  </ul>
  
  <p>This is my CustomerAPI.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;api context="/customers" name="CustomersAPI" 
  xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;resource methods="POST GET" uri-template="/"&gt;
          &lt;inSequence&gt;
              &lt;log level="custom" separator="&amp;#xa;"&gt;
                  &lt;property name="API CUSTOMER" value="START"/&gt;
              &lt;/log&gt;
              &lt;sequence key="LoginCheckSeq"/&gt;
              &lt;sequence key="CreateBearerTokenSeq"/&gt;
              &lt;sequence key="GetCustomersSeq"/&gt;
         &lt;/inSequence&gt;
         &lt;outSequence&gt;
          &lt;log&gt;
              &lt;property expression="$axis2:HTTP_SC" name="Status Code" xmlns:ns="http://org.apache.synapse/xsd"/&gt;
          &lt;/log&gt;
          &lt;/outSequence&gt;
          &lt;faultSequence&gt;
          &lt;log level="full"/&gt;
          &lt;/faultSequence&gt;
      &lt;/resource&gt;
  &lt;/api&gt;
  </code></pre>
  
  <p>LoginCheckSeq.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence name="LoginCheckSeq" trace="disable" 
  xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;log level="custom" separator="&amp;#xa;"&gt;
          &lt;property name="Login SEQUENCE" value="START"/&gt;
      &lt;/log&gt;
      &lt;property expression="json-eval($.username)" name="uri.var.username" scope="default" type="STRING"/&gt;
      &lt;property expression="json-eval($.password)" name="uri.var.password" scope="default" type="STRING"/&gt;
      &lt;log level="custom" separator=","&gt;
          &lt;property expression="fn:concat('Username : ', get-property('uri.var.username'), ' / Password : ',get-property('uri.var.password')) " name="PARAMS"/&gt;
          &lt;/log&gt;
          &lt;call&gt;
              &lt;endpoint key="LoginCheckEP"/&gt;
          &lt;/call&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>CreateBearerToken.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence name="CreateBearerTokenSeq" trace="disable" 
  xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;log level="custom" separator="&amp;#xa;"&gt;
          &lt;property name="Create Bearer Token SEQUENCE" value="START"/&gt;
      &lt;/log&gt;
      &lt;payloadFactory media-type="json"&gt;
          &lt;format&gt;{"token":"$1"}&lt;/format&gt;
          &lt;args&gt;
              &lt;arg evaluator="json" expression="$.token"/&gt;
          &lt;/args&gt;
      &lt;/payloadFactory&gt;
      &lt;property name="messageType" value="application/json" scope="axis2"/&gt;
      &lt;property expression="json-eval($.token)" name="uri.var.jwt.token" scope="default" type="STRING"/&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>GetCustomerSeq.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence name="GetCustomersSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;log description="" level="custom" separator="&amp;#xa;"&gt;
          &lt;property name="Get Customer SEQUENCE" value="START"/&gt;
      &lt;/log&gt;
      &lt;log description="" level="custom" separator="##"&gt;
          &lt;property expression="fn:concat('Bearer ', get-property('uri.var.jwt.token'))" name="JWT Token Created"/&gt;
      &lt;/log&gt;
      &lt;header name="Authorization" expression="fn:concat('Bearer ', get-property('uri.var.jwt.token'))" scope="transport"/&gt;
      &lt;send&gt;
          &lt;endpoint key="GetCustomersEP"/&gt;
      &lt;/send&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>I get well the JWT Token from LoginCechkSeq but i have an error in the getCustomerSeq.</p>
  
  <p>This is the error : </p>
  
  <pre><code>[2018-08-14 15:14:07,510] [EI-Core]  INFO - LogMediator API CUSTOMER = START
  [2018-08-14 15:14:07,511] [EI-Core]  INFO - LogMediator Login SEQUENCE = START
  [2018-08-14 15:14:07,511] [EI-Core]  INFO - LogMediator PARAMS = Username : test@test.fr / Password : Azerty123
  [2018-08-14 15:14:08,586] [EI-Core]  INFO - LogMediator Create Bearer Token SEQUENCE = START
  [2018-08-14 15:14:08,591] [EI-Core]  INFO - LogMediator Get Customer SEQUENCE = START
  [2018-08-14 15:14:08,591] [EI-Core]  INFO - LogMediator JWT Token Created = Bearer eyJhbGciOiJSUzI1NiJ9.eyJyb2xlcyI6WyJST0xFX1VTRVJfTUFUT09NQSIsIlJPTEVfVVNFUiJdLCJ1c2VybmFtZSI6InRlc3RAdGVzdC5mciIsImZpcnN0TmFtZSI6I    kxvXHUwMGVmYyIsImxhc3ROYW1lIjoiQ2FyaW91IiwiaWQiOjIwLCJpYXQiOjE1MzQyNTI0NDgsImV4cCI6MTUzNDI2Njg0OH0.Gx_cSwXE0rm1EZSPeI64cbOdysjXcLwj2NYjtNE4eh_gtUSwbCE2EUPL6sB-Rt_ayQOeOEx-w07Bkbh-Rr6rUd-mqnKXHuUCe76pOXWWW5ejV7k8n_    Tf3gk4upbzn77VMsyNALWJYNBSO4S8dDCyp413SRvnRaKuhkF1GgvkbZx7aJNUwkDA_ZuxG3IfOKQdao7GgDhWH9pltH9zIjXtjagbjRPgBaekcZiB2bxglQLF7RUMky2MVG_WEbcLFms14LiIEooG3lXao73Z2foYXSMxReHHAmhGPfSipw_wA9ohMolB_X5Ck13O0tSDUvsqvqdZHPZ    w8ITmn_4pKnJhTiCK6U58Ub_Nr6Royeiwf3_WN7ooqOczF0hbJr7ZFONo3BwKEhCj6gPv9gknK0ahSotnsRvQS56VsquWJm9ZwtXAI2D0J8tNjSmxMP9FWbmFMWap2wOayUEGpauYD3WA5W-CZexqulJTbLSPcMF92QWaKMoVtL5blgGt9vTb1YIVnQi4KALK9psJETgcvHCIbfsN    E_IcYMlotIHRuO4RR-j0I7WAxQVko9YNkIRpuDUftpUq95TbIxn5NeTFhWL_NoC2F3jO4khGYR-Hk2P2ZudygrrdmDMfezn7d5yArV7mlukSB6chwq38T261ktzqx_G_rHt1pjt0jXVhz1DPsY4
  [2018-08-14 15:14:10,087] [EI-Core] ERROR - RelayUtils Error while building Passthrough stream
  org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '&lt;'
   at [row,col {unknown-source}]: [1,1]
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
      at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
      at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:165)
      at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:163)
      at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:116)
      at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:145)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:94)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
      at org.apache.synapse.rest.Resource.process(Resource.java:351)
      at org.apache.synapse.rest.API.process(API.java:338)
      at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
      at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
      at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:56)
      at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:570)
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:193)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
      at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '&lt;'
   at [row,col {unknown-source}]: [1,1]
      at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
      at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052)
      at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
      at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
      at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
      ... 24 more
  </code></pre>
  
  <p>I tried several thing like add this line : </p>
  
  <pre><code>&lt;messageBuilder contentType="application/json" class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/&gt;  
  </code></pre>
  
  <p>Or add property with name "messageType" with value "application/json"</p>
  
  <p>But nothing resolve my problem...
  If someone has already encountered this problem, I'm taking the solution =)</p>