title: WSO2 PayloadFactory mediator empty arguments
body: <p>in my WSO2 ESB 4.7.0 i have configured this proxy:</p>
  
  <pre><code>&lt;proxy xmlns="http://ws.apache.org/ns/synapse" name="SendingByJmsAddressProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true"&gt;
   &lt;target&gt;
      &lt;inSequence&gt;
         &lt;send&gt;
            &lt;endpoint&gt;
               &lt;address uri="http://localhost:8080/RestService/rest/servizio"/&gt;
            &lt;/endpoint&gt;
         &lt;/send&gt;
      &lt;/inSequence&gt;
      &lt;outSequence&gt;
         &lt;log&gt;
            &lt;property name="codice" expression="//codice"/&gt;
         &lt;/log&gt;
         &lt;log level="full"/&gt;
         &lt;switch source="//codice"&gt;
            &lt;case regex="asd"&gt;
               &lt;send/&gt;
            &lt;/case&gt;
            &lt;case regex="0"&gt;
               &lt;log&gt;
                  &lt;property name="codice" value="check1"/&gt;
               &lt;/log&gt;
               &lt;send/&gt;
               &lt;payloadFactory media-type="xml"&gt;
                  &lt;format&gt;
                     &lt;code&gt;$1&lt;/code&gt;
                  &lt;/format&gt;
                  &lt;args&gt;
                     &lt;arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" evaluator="xml"
                          expression="//codice"/&gt;
                  &lt;/args&gt;
               &lt;/payloadFactory&gt;
               &lt;property name="messageType" value="application/xml"/&gt;
               &lt;log level="full"/&gt;
               &lt;send&gt;
                  &lt;endpoint&gt;
                     &lt;address uri="jms:/testQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/jndi.properties&amp;transport.jms.DestinationType=queue"/&gt;
                  &lt;/endpoint&gt;
               &lt;/send&gt;
            &lt;/case&gt;
         &lt;/switch&gt;
      &lt;/outSequence&gt;
   &lt;/target&gt;
   &lt;description/&gt;
  &lt;/proxy&gt;
  </code></pre>
  
  <p>In the inSequence i forward the client's request to a Rest Service whose response is a json string that looks like this:</p>
  
  <pre><code>{
    "codice":"0",
    "messaggio":"Operazione effettuata 18:12",
    "path":"\/path\/1AASSCOGNOME_NOME.111.2231\/",
    "documenti":[{
              "idAggregatoContenitore":"3508",
              "idDocumento":"016601",
              "idVersione":"17010",
              "numVersione":"1",
              "tipoDocumento":"Documento",
              "autore":"sysadmin",
              "titolo":"prova1",
              "fileName":"FStandard.xml",
              "checkedOut":"false",
              "idDocumentoPadre":"",
              "flagAllegati":"false",
              "flagDaProtocollare":"true",
              "dataCreazione":"11\/02\/2013 19:05",
              "dataChekin":"11\/02\/2013 19:05",
              "mimeType":"text\/xml",
              "empty":"false",
              "data":"1660100000",
              "cache":"false",
              "tipo":"D",
              "nome":"prova1",
              "keyData":"16601",
              "keyNome":"prova1",
              "keyNumero":"",
              "keyTipo":"D",
              "fileExtension":"path\/xml_file.png",
              "evidenza":"false",
              "originalDocumentoPadreId":"",
              "originalDocumentoId":"016601",
              "originalAggregatoContenitoreId":"3508"
            },
            {
              "idAggregatoContenitore":"3508",
              "idDocumento":"016602",
              "idVersione":"17011",
              "numVersione":"1",
              "tipoDocumento":"Documento",
              "autore":"sysadmin",
              "titolo":"123456789",
              "fileName":"HTTP Proxy Server.jmx",
              "checkedOut":"false",
              "idDocumentoPadre":"",
              "flagAllegati":"false",
              "flagDaProtocollare":"true",
              "dataCreazione":"11\/02\/2013 19:19",
              "dataChekin":"11\/02\/2013 19:19",
              "mimeType":"application\/octet-stream",
              "empty":"false",
              "data":"1660200000",
              "cache":"false",
              "tipo":"D",
              "nome":"123456789",
              "keyData":"16602",
              "keyNome":"123456789",
              "keyNumero":"",
              "keyTipo":"D",
              "fileExtension":"path\/Documento.png",
              "evidenza":"false",
              "originalDocumentoPadreId":"",
              "originalDocumentoId":"016602",
              "originalAggregatoContenitoreId":"3508"
            }],
    "data":"350800000",
    "tipoAggregatoEnum":"R",
    "statoEnum":"aperto",
    "keyData":"1360602720000",
    "keyNome":"1aasscognome_nome.111.2231",
    "nomeAggregatoNoNumero":"1AASSCOGNOME_NOME.111.2231",
    "keyNumero":"1AASSCOGNOME_NOME.111.2231",
    "keyTipo":"R",
    "originalAggregatoId":"3508",
    "originalAggregatoPadre":"3108"
  }
  </code></pre>
  
  <p>As standard behaviour ESB converts the incoming json message into an xml formatted message.
  Now in the outSequence i want:</p>
  
  <p>1)sending back the RestService response to the client: by the  mediator</p>
  
  <p>2)then i want to build an xml message extracting some elements from the message payload and then to send it by jms protocol elsewhere.</p>
  
  <p>The proxy works fine all but the PayloadFactory mediator. Indeed the message built by the Payload Factory mediator has its body empty:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;Body&gt;
    &lt;code xmlns="http://ws.apache.org/ns/synapse"/&gt;
  &lt;/Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>could anyone tell me why the specified arg tag is empty (the xpath expression seems to be correct)? what's wrong?
  Thanks</p>