WSO2 EI: HTTPSender Unable to sendViaPost to url - wso2
I am using WSO2 EI 6.4.0
I have created an API which will call external URL to get the information. Below is my code for an API in WSO2 EI
<?xml version="1.0" encoding="UTF-8"?>
<api context="/api/seqadd" name="seq_mediator" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET">
<inSequence>
<property name="basicAuth" scope="default" type="STRING" value="xxxxx"/>
<property name="grant_type" scope="default" type="STRING" value="client_credentials"/>
<property name="scope" scope="default" type="STRING" value="vvv/.drer"/>
<payloadFactory media-type="xml">
<format>
<root>
<grant_type>$1</grant_type>
<scope>$2</scope>
</root>
</format>
<args>
<arg1 evaluator="xml" expression="$ctx:grant_type"/>
<arg2 evaluator="xml" expression="$ctx:scope"/>
</args>
</payloadFactory>
<property expression="fn:concat('Basic ', get-property('basicAuth'))" name="Authorization" scope="transport" type="STRING"/>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<property expression="$body/*" name="payload created"/>
<property expression="get-property('axis2','REST_URL_POSTFIX')" name="resource" scope="default" type="STRING"/>
<property action="remove" name="REST_URL_POSTFIX" scope="default"/>
<call blocking="true">
<endpoint name="URL">
<http method="post" uri-template="https://example.com/login/v1.0/token"/>
</endpoint>
</call>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property expression="json-eval($.access_token)" name="Authorization" scope="default" type="STRING"/>
<property expression="fn:concat('Bearer ', get-property('Authorization'))" name="Authorization" scope="transport" type="STRING"/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
When calling this API, I am getting below error
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> GET /api/seqadd HTTP/1.0
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> X-Forwarded-Host: example.com
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> X-Forwarded-Server: example.com
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> Connection: close
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> Content-Type: application/x-www-form-urlencoded
[2020-03-02 14:36:52,829] [EI-Core] DEBUG - headers http-incoming-2 >> User-Agent: PostmanRuntime/7.22.0
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Accept: */*
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Cache-Control: no-cache
[2020-03-02 14:36:52,830] [EI-Core] DEBUG - headers http-incoming-2 >> Accept-Encoding: gzip, deflate, br
[2020-03-02 14:36:52,983] [EI-Core] DEBUG - header >> "POST /login/v1.0/token HTTP/1.1[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Content-Type: application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Accept: */*[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Authorization: Basic xxxxx[\r][\n]"
[2020-03-02 14:36:52,989] [EI-Core] DEBUG - header >> "Cache-Control: no-cache[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "X-Forwarded-Host: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "X-Forwarded-Server: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "User-Agent: Axis2[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "Host: example.com[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "Transfer-Encoding: chunked[\r][\n]"
[2020-03-02 14:36:52,990] [EI-Core] DEBUG - header >> "[\r][\n]"
[2020-03-02 14:36:52,991] [EI-Core] DEBUG - content >> "53[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "grant_type=client_credentials&scope=vvv%2F.drer"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "0"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:52,992] [EI-Core] DEBUG - content >> "[\r][\n]"
[2020-03-02 14:36:53,001] [EI-Core] DEBUG - header << "HTTP/1.1 404 Not Found[\r][\n]"
[2020-03-02 14:36:53,001] [EI-Core] DEBUG - header << "HTTP/1.1 404 Not Found[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "Cache-Control: private[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "Strict-Transport-Security: max-age=31536000; includeSubDomains[\r][\n]"
[2020-03-02 14:36:53,002] [EI-Core] DEBUG - header << "X-Content-Type-Options: nosniff[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Set-Cookie: x-ms-gateway-slice=prod; path=/; SameSite=None; secure; HttpOnly[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Date: Mon, 02 Mar 2020 14:36:52 GMT[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "Content-Length: 0[\r][\n]"
[2020-03-02 14:36:53,003] [EI-Core] DEBUG - header << "[\r][\n]"
[2020-03-02 14:36:53,006] [EI-Core] INFO - HTTPSender Unable to sendViaPost to url[https://example.com/login/v1.0/token]
org.apache.axis2.AxisFault: Transport error: 404 Error: Not Found
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:371)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:81)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:459)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:286)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:441)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:227)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:490)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:382)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:88)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:547)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384)
at org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85)
at org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:164)
at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:119)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
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:399)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
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)
I have added the SSL certificate for the token URL as well. Can some one please guide.
I am able to get the token URL working from Postman. I am not getting what could go wrong here, as this is common API and I have used earlier as well for other URls.
Thanks
Related
Convert SoapUI Request into CFHTTP
I am looking at a request in SoapUI that is sending header info to a specific endpoint but I am having a hard time recreating it in ColdFusion. Below is what the RAW request looks like in SoapUI: >> "GET https://test-01.mywebsite.com/data_api//1.0/service/requests HTTP/1.1[\r][\n]" >> "Accept-Encoding: gzip,deflate[\r][\n]" >> "Authorization: Bearer A1BEC30F7E0273059E775A6A2645E273[\r][\n]" >> "Host: test-01.mywebsite.com[\r][\n]" >> "Connection: Keep-Alive[\r][\n]" >> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]" >> "[\r][\n]" << "HTTP/1.1 200 OK[\r][\n]" << "Pragma: No-cache[\r][\n]" << "Cache-Control: no-cache[\r][\n]" << "Expires: Wed, 31 Dec 1969 16:00:00 PST[\r][\n]" << "Content-Type: application/json;charset=UTF-8[\r][\n]" << "Content-Length: 6796[\r][\n]" << "Date: Fri, 13 May 2016 15:40:08 GMT[\r][\n]" << "Server: hws[\r][\n]" << "Set-Cookie: X-HR-ClientSessionId=2_10.85.12.121_1463154008475;Secure; path=/; HttpOnly[\r][\n]" << "Content-Encoding: deflate[\r][\n]” I am not sure if I am not formatting the Authorization header correctly or what but any help would be great. EDIT I got a RAW HTML output from the client which I have updated above. I am still trying to recreate that header in ColdFusion. My New question(s): Do the "New Line" characters make a difference in the header values? Should I also add a parameter for the content type? I did try the following: <cfset NL="Bearer BD4DF031B24180C9338F0D9F060556A7" & Chr(10) & Chr(13)/> <cfhttp method="get" url="https://test-01.mywebsite.com/data_api//1.0/service/requests" result="orderList"> <cfhttpparam type="HEADER" name="Authorization" value="#NL#"> <cfhttpparam type="Header" name="Accept-Encoding" value="gzip,deflate"> </cfhttp> <cfset CurrentOrders = deserializeJSON(orderList.filecontent)> <cfdump var="#CurrentOrders#"> When I dump everything from the cfhttp call I get: struct Charset UTF-8 ErrorDetail [empty string] Filecontent Connection Failure Header HTTP/1.1 200 OK Connection: close Expires: Wed, 31 Dec 1969 16:00:00 PST Date: Tue, 17 May 2016 19:23:36 GMT Server: hws Pragma: No-cache Cache-Control: no-cache Set-Cookie: X-HR-ClientSessionId=3_12.161.115.226_1463513016026;Secure; path=/; HttpOnly Content-Type: application/json;charset=UTF-8 Mimetype application/json Responseheader struct Cache-Control no-cache Connection close Content-Type application/json;charset=UTF-8 Date Tue, 17 May 2016 19:23:36 GMT Expires Wed, 31 Dec 1969 16:00:00 PST Explanation OK Http_Version HTTP/1.1 Pragma No-cache Server hws Set-Cookie X-HR-ClientSessionId=3_12.161.115.226_1463513016026;Secure; path=/; HttpOnly Status_Code 200 Statuscode 200 OK Text NO I am getting a 200 OK status code but still getting a Connection Failure.
It looks like you're double encrypting your security token. I modified your code so I could capture the request with Fiddler as per Leighs Answer. To get ColdFusion to send the traffic through Fiddler I modified Dmitri Pisarenko answer for http and added it to my JVM Arguments. <cfhttp method="get" url="http://localhost/data_api/1.0/service/requests" result="orderList"> <cfhttpparam type="HEADER" name="Authorization" value="Basic #ToBase64("Bearer 6EDC52118E164AE659EA2C772F3B9804")#"> <cfhttpparam type="Header" name="Accept-Encoding" value="gzip,deflate"> </cfhttp> The head I get leaving the cfhttp request is: GET http://localhost/data_api/1.0/service/requests HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko Accept-Encoding: gzip,deflate Connection: close Authorization: Basic QmVhcmVyIDZFREM1MjExOEUxNjRBRTY1OUVBMkM3NzJGM0I5ODA0 Host: localhost Connection: Keep-Alive As you can see, the Authorization header isn't the same as what SoapUI created. I modified the value of the Authorization param to : "Bearer 6EDC52118E164AE659EA2C772F3B9804" and I get a header with an authentication header that matches the raw header from SoapUI: GET http://localhost/data_api/1.0/service/requests HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko Accept-Encoding: gzip,deflate Connection: close Authorization: Bearer 6EDC52118E164AE659EA2C772F3B9804 Host: localhost Connection: Keep-Alive
Invoking token using ajax (WSO2 APIManager1.10)
I 'd like invoking the token at APIM 1.10 using ajax. I tryed this: $(function() { $.ajax({ url:'https://localhost:9443/token', type: 'POST', dataType: 'json', contentType: 'application/json', data:{ 'grant_type':'client_credentials' }, headers:{ 'Authorization': 'Basic Q3dLYmJybWhDUnJpMVJlMDIycWp0UGtxWUlrYTpjYzZQMkVFOEVJRDNqSWRSN2ZnRUoyUDU2ajRh', }, success:function(e){ $('#token').html(e); } }); }); But didn't receved nothing. Just a empty option request. API Manager show this: [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> OPTIONS /token HTTP/1.0 [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> X-Forwarded-Host: <My host> [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> X-Forwarded-Server: <My Host> [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> X-Forwarded-For: <My IP> [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> Host: <My Host> [2016-03-30 14:48:40,340] DEBUG - headers http-incoming-1 >> Connection: close [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:41.0) Gecko/20100101 Firefox/41.0 [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3 [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Accept-Encoding: gzip, deflate [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Origin: null [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Access-Control-Request-Method: POST [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Access-Control-Request-Headers: authorization,content-type [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Pragma: no-cache [2016-03-30 14:48:40,341] DEBUG - headers http-incoming-1 >> Cache-Control: no-cache [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << HTTP/1.0 200 OK [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << Access-Control-Request-Headers: authorization,content-type [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << Host: <My Host> [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << X-Forwarded-Server: <My Host> [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << Origin: null [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << Access-Control-Request-Method: POST [2016-03-30 14:48:40,386] DEBUG - headers http-incoming-1 << Cache-Control: no-cache [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Pragma: no-cache [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << X-Forwarded-Host: <My Host> [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3 [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Allow: POST [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Accept-Encoding: gzip, deflate [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << X-Forwarded-For: <my ip> [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Date: Wed, 30 Mar 2016 17:48:40 GMT [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Server: WSO2-PassThrough-HTTP [2016-03-30 14:48:40,387] DEBUG - headers http-incoming-1 << Connection: Close [2016-03-30 14:48:40,389] DEBUG - wire << "HTTP/1.0 200 OK[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Access-Control-Request-Headers: authorization,content-type[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Host: <my host name>[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "X-Forwarded-Server: <my host>[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Origin: null[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Access-Control-Request-Method: POST[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Cache-Control: no-cache[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Pragma: no-cache[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "X-Forwarded-Host: <My Host NAME>[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Allow: POST[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "Accept-Encoding: gzip, deflate[\r][\n]" [2016-03-30 14:48:40,390] DEBUG - wire << "X-Forwarded-For: <My computer IP>[\r][\n]" [2016-03-30 14:48:40,391] DEBUG - wire << "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[\r][\n]" [2016-03-30 14:48:40,391] DEBUG - wire << "Date: Wed, 30 Mar 2016 17:48:40 GMT[\r][\n]" [2016-03-30 14:48:40,391] DEBUG - wire << "Server: WSO2-PassThrough-HTTP[\r][\n]" [2016-03-30 14:48:40,391] DEBUG - wire << "Connection: Close[\r][\n]" [2016-03-30 14:48:40,391] DEBUG - wire << "[\r][\n]" Does somebody know how can I do this? Thanks, Eliezer Trajano
Here the problem is content type.The content type should be application/x-www-form-urlencoded according to documentation and you need to remove the json data type as well.With above changes the ajax code should be as follows $(function() { $.ajax({ url:'https://localhost:9443/oauth2/token', type: 'POST', contentType: 'application/x-www-form-urlencoded', data:{ 'grant_type':'client_credentials' }, headers:{ 'Authorization': 'Basic Q3dLYmJybWhDUnJpMVJlMDIycWp0UGtxWUlrYTpjYzZQMkVFOEVJRDNqSWRSN2ZnRUoyUDU2ajRh', }, success:function(e){ $('#token').html(e); } }); });
wso2 esb 4.8.1 callout mediator and multipart/form-data bug?
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
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
WSO2 ESB sending MTOM encoded request from proxy service
I need to send MTOM encoded request from WSO2 ESB proxy service. I'm setting parameters: <property name="enableMTOM" value="true" scope="axis2" type="STRING"/> <property name="messageType" value="multipart/related" scope="axis2" type="STRING"/> and it works fine. Headers of the request: POST /alfresco/cmisws/DiscoveryService HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: multipart/related; boundary="MIMEBoundary_a62df4c2a350faee72d4e9faf54c07e7135aa06bcf30bf02"; type="application/xop+xml"; start="<0.b62df4c2a350faee72d4e9faf54c07e7135aa06bcf30bf02#apache.org>"; start-info="text/xml" SOAPAction: "urn:mediate" Transfer-Encoding: chunked Host: 127.0.0.1:8181 Connection: Keep-Alive User-Agent: Synapse-PT-HttpComponents-NIO 67b --MIMEBoundary_a62df4c2a350faee72d4e9faf54c07e7135aa06bcf30bf02 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: <0.b62df4c2a350faee72d4e9faf54c07e7135aa06bcf30bf02#apache.org> But I need to call my proxy service as HTTP GET. So when I need to send MTOM encoded request from proxy service, I'm setting additional attribute format="soap11" in the endpoint definition. And message is no longer MTOM encoded - Content-Type is text/xml. POST /alfresco/cmisws/DiscoveryService HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: text/xml Transfer-Encoding: chunked Host: 127.0.0.1:8181 Connection: Keep-Alive User-Agent: Synapse-PT-HttpComponents-NIO 678 --MIMEBoundary_c62df4c2a350faee60d6513af54c07e7035aa06bcf30bf02 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: <0.d62df4c2a350faee60d6513af54c07e7035aa06bcf30bf02#apache.org> Without format="soap11" attribute I'am getting error SequenceMediator Error while building message org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,530] Message: The element type "body" must be terminated by the matching end-tag "</body>". at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296) Sequence deffinition: <sequence xmlns="http://ws.apache.org/ns/synapse" name="GetDocIdFromAlfresco"> <property name="enableMTOM" value="true" scope="axis2" type="STRING"/> <property name="messageType" value="multipart/related" scope="axis2" type="STRING"/> <payloadFactory media-type="xml"> . . . </payloadFactory> <call> <endpoint> <address uri="http://localhost:8080/alfresco/cmisws/DiscoveryService" format="soap11"/> </endpoint> </call> <respond/> </sequence> How can I send MTOM encoded request from proxy service called as HTTP GET?
You can not send multipart with GET request, as it should not contain body, only a header.
I encountered this before: it seems that ESB does not allow creating a mtom-enabled get-request, because there is no content to mtom-ifie. But for CMIS, you really need this: the CMIS specs specify that all request, also the GET requests, should be encoded. In the end I worked around it by creating a custom mediator that does all CMIS contact via the OpenCMIS java api.
WSO2 ESB FORCE_HTTP_1.0 not working
I'm trying to force the WSO2 to set the http version to 1.0 because the client of a service requires the Content-Length property. I configured the following properties in the outSequence, before the <send/>: <property name="FORCE_HTTP_1.0" value="true" scope="axis2"/> <property name="DISABLE_CHUNKING" value="true" scope="axis2"/> but it doesn't works! The response header: HTTP/1.0 200 OK userAgent: Synapse-PT-HttpComponents-NIO Host: localhost:8280 SOAPAction: "sendMessage" Accept-Encoding: gzip,deflate Content-Type: text/xml; charset=UTF-8 Server: WSO2-PassThrough-HTTP Date: Thu, 13 Mar 2014 21:55:25 GMT Connection: Close I'm using ESB 4.6.0 and SoapUI to call the service. Why the Content-Length doesn't appears? What's wrong?
This is a bug in ESB and we fixed it recently. https://wso2.org/jira/browse/ESBJAVA-2985 The properties you mentioned are not working in outSequence path. The fix should be available in next release. The patch for Synapse transport is also attached in ESBJAVA-2985 and you may patch the Synapse version in your WSO2 ESB.