wso2 Missing boundary in multipart/form-data POST

Viewed 1430

I'm trying to implement this scenario:

wso2Proxy sends POST to joao.php

joao.php gets id value and returns it.

if i call joao.php from a browser and a form with a field called id it works. If i do the same in WSO2 Proxy i get the php error Missing boundary in multipart/form-data POST.

I used TCPMon to analyse the calls and WSO2 sends Content-Type: multipart/form-data but no boundary.

Can someone point me in the right direction?

Here are the 2 calls:

From Browser:

POST /joao.php HTTP/1.1
Host: localhost:7590
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytcskUke6yP5MNOzt
Origin: http://localhost:7590
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Referer: http://localhost:7590/joao.php
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Length: 135
Connection: keep-alive

------WebKitFormBoundarytcskUke6yP5MNOzt
Content-Disposition: form-data; name="id"

sd
------WebKitFormBoundarytcskUke6yP5MNOzt--

From WSO2 Proxy:

POST /joao.php HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 264
Host: localhost:7590
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO

--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba
Content-Disposition: form-data; name="id"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit

teste123
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba--

I have the following commented sections on axis2.xml:

<!--messageFormatter contentType="multipart/form-data"
                    class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->

<!--messageBuilder contentType="multipart/form-data"
                    class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->

This is because if I enable them then the content gets posted as XML and not multipart/data.

As a result, these are the builders and formatters that are enabled for multipart/data:

<messageFormatter class="org.apache.axis2.transport.http.MultipartFormDataFormatter" contentType="multipart/form-data"/>

<messageBuilder class="org.apache.axis2.builder.MultipartFormDataBuilder" contentType="multipart/form-data"/>

Here is the proxy configuration I am using:

<proxy xmlns="http://ws.apache.org/ns/synapse"
   name="testeSendFile"
   transports="http https"
   startOnLoad="true">
<description/>
<target>
  <inSequence>
     <payloadFactory media-type="xml">
        <format>
           <params xmlns="">
              <id>teste123</id>
           </params>
        </format>
        <args/>
     </payloadFactory>
     <property name="messageType" value="multipart/form-data" scope="axis2"/>
     <property name="DISABLE_CHUNKING"
               value="true"
               scope="axis2"
               type="STRING"/>
     <log level="full"/>
     <send>
        <endpoint>
           <http method="POST" uri-template="http://localhost:7590/joao.php"/>
        </endpoint>
     </send>
     <log level="full"/>
  </inSequence>
</target>
</proxy>
3 Answers

This is a bug. Will be fixed in next release.

I was able to resolve the issue by changing the proxy service to the following.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
     name="testeSendFile"
     startOnLoad="true"
     statistics="disable"
     trace="disable"
     transports="http,https">
  <target>
    <outSequence>
       <property name="OUT_ONLY" value="true"/>
       <send/>
    </outSequence>
    <endpoint>
       <address uri="http://localhost:8080/upload"/>
    </endpoint>
  </target>
  <description/>
</proxy>

For more detailed information refer to the following bolg.

Ushani Balasooriya's Blog

Here is the sample request

enter image description here

Related