title: WSO2 ESB Payload Factory creates invalid SOAP envelope
body: <p>I am trying to translate a REST request to a SOAP request in WSO2's ESB. Therefore I created an API in the ESB that offers the REST endpoint. In this API each resource has an In-Sequence that contains a Payload Factory Mediator. This mediator translates the REST request to a SOAP message. The SOAP message is then send to a custom ESB proxy that I had defined previously. </p>
  
  <p>Here is the issue: When I send a REST request the request gets processed and translated to SOAP, but the response HTML status code is 500. As a consequence I activated the SOAP Message Tracer in the ESB to check, what messages are coming in and to check how the messages look like that are created by the Payload Factory Mediator.</p>
  
  <p>The resulting SOAP message of the Payload Factory looks definitely wrong, like this:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soapenv:Body&gt;
       &lt;soapenv:Envelope&gt;
          &lt;soapenv:Body&gt;
             &lt;mms:getCarData xmlns:mms="mms.cardiag"/&gt;
          &lt;/soapenv:Body&gt;
       &lt;/soapenv:Envelope&gt;
    &lt;/soapenv:Body&gt;
  </code></pre>
  
  <p></p>
  
  <p>As you can easily see, there is a second <code>&lt;soapenv:Envelope&gt;</code> + body created in the message. I can't figure out why this happens, crucially since I followed the <a href="http://docs.wso2.org/display/ESB460/Sample+800%3a+Introduction+to+REST+API" rel="nofollow">Example 800</a> of the WSO2 documentation very closely.</p>
  
  <p>I provide the implementation of a resource in my REST API as well, so you can check my configuration of the Payload Factory Mediator. I am sure I am missing something important, but I cannot figure out what, unfortunately.</p>
  
  <pre><code>&lt;resource methods="GET" uri-template="/cardata"&gt;
    &lt;inSequence&gt;
       &lt;payloadFactory media-type="xml"&gt;
          &lt;format&gt;
             &lt;mms:getCarData xmlns:mms="mms.cardiag"/&gt;
          &lt;/format&gt;
          &lt;args/&gt;
       &lt;/payloadFactory&gt;
       &lt;log level="full" category="TRACE"/&gt;
       &lt;send&gt;
          &lt;endpoint&gt;
             &lt;address uri="http://wso2-1:8280/services/TestProxy" format="soap11"/&gt;
          &lt;/endpoint&gt;
       &lt;/send&gt;
    &lt;/inSequence&gt;
    &lt;outSequence&gt;
       &lt;send/&gt;
    &lt;/outSequence&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks for your help!</p>