0
votes

We are having problems with callout and multipart/form-data Our api is for upload a file We have this builder and formater configured

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

But in execution we see that org.wso2.carbon.relay.BinaryRelayBuilder is used, but when we call an endpoint with callout mediator the message formater that is executed is MultipartFormDataBuilder instead ExpandingMessageFormatter, that make that the attachment don't arrive to the endpoint (we supose this is a bug)

<api xmlns="http://ws.apache.org/ns/synapse" name="CloneTest" context="/cloneTest">
   <resource methods="POST" uri-template="/test6">
      <inSequence>
         <sequence key="Clone3Sequence"></sequence>
         <log level="full">
            <property name="***** IN Estoy en el GET /cloneTest/test5 sequence11- $.clave = " expression="json-eval($.clave)"></property>
         </log>
         <drop></drop>
      </inSequence>

<sequence xmlns="http://ws.apache.org/ns/synapse" name="Clone3Sequence" trace="disable">
   <property name="HTTP_METHOD" value="POST" scope="axis2"></property>
   <callout serviceURL="http://localhost:1234/ProyectoWebMultipartForm/UploadServlet/recurso1">
      <source type="envelope"></source>
      <target key="RESPUESTA"></target>
   </callout>
   <property xmlns:ns="http://org.apache.synapse/xsd" name="RESPUESTAAAAAAAA" expression="get-property('RESPUESTA')"></property>
</sequence>   

Request that arrive to the esb

POST /cloneTest/test6 HTTP/1.1
Host: 127.0.0.1:1234
Connection: keep-alive
Content-Length: 300
Cache-Control: no-cache
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
apikey: b7608e32c2bb4aaa85c47584bf1b5508
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryNuCtYYL1ByZXkmrY
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Postman-Token: 218244a6-8fc3-1911-b2db-22ff2bf93bd1
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: es-ES,es;q=0.8

------WebKitFormBoundaryNuCtYYL1ByZXkmrY
Content-Disposition: form-data; name="payload"

{"a","b"}
------WebKitFormBoundaryNuCtYYL1ByZXkmrY
Content-Disposition: form-data; name="file"; filename="prueba.txt"
Content-Type: text/plain

pruebaaaaaaaa
------WebKitFormBoundaryNuCtYYL1ByZXkmrY--

Request that arrive to the endpoint

POST /ProyectoWebMultipartForm/UploadServlet/recurso1/test6 HTTP/1.1
Content-Type: multipart/form-data; charset=UTF-8; boundary=MIMEBoundary_02d66e5320a1bf4a46f61b9faa892f7837ffed6e9ee5e74d
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: es-ES,es;q=0.8
apikey: b7608e32c2bb4aaa85c47584bf1b5508
Cache-Control: no-cache
Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
Postman-Token: 218244a6-8fc3-1911-b2db-22ff2bf93bd1
User-Agent: Axis2
Host: 127.0.0.1:1234
Transfer-Encoding: chunked

0

We supose that this is a bug in WSO2 4.8.1 version, could someone confirm this to us?

Thanks in advance

1

1 Answers

1
votes

Did you check the defined message formatters and builders in the ESB_HOME/repository/conf/axis2/axis2_blocking_client.xml for the specific contentType(multipart/form-data) because callout mediator is using for sending request as a blocking way. So it is internally using axis2_blocking_client.xml