How to Remove charset=utf-8 in WSO2 ESB - wso2

I have a requirement to call rest service, which accept "Content-Type: application/json" in header but when I try to call it from ESB. WSO2 adds "charset=utf-8" automatically. I am not sure how to remove it.
I have also used ContentType property but no luck.
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="PUT"/>
<property name="ContentType" scope="axis2" type="STRING" value="application/json"/>
<header expression="fn:concat('Basic ', get-property('ENCODED_URL'))" name="Authorization" scope="transport" xmlns:ns="http://org.apache.synapse/xsd"/>
<payloadFactory media-type="json">
<format>{
"name": "XXX_Token",
"type": "XXXX-cf04186e2156_sessionID",
"version": "1.0.1",
"Attribute-N": $1
}
</format>
<args>
<arg expression="$ctx:XXXTokenValue" literal="false" />
</args>
</payloadFactory>
<property name="REST_URL_POSTFIX" scope="axis2" value=""/>
<call>
<endpoint>
<address trace="disable" uri="https://XXXXX:9493/governance/restservices/52b1caba-b507-4f6a-95bc-2ea7b2418e67"/>
</endpoint>
</call>
Logs:
- End : Call mediator - Non Blocking Call
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "PUT /governance/restservices/5XXXXX2ea7b2418e67 HTTP/1.1[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "X-AspNet-Version: 4.0.30319[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Authorization: Basic YWRtaW46YWRtaW4=[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Content-Type: application/json; charset=utf-8[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "X-Powered-By: ASP.NET[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Cache-Control: private, max-age=0[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Transfer-Encoding: chunked[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Host: XXXXXXz:9493[\r][\n]"
TID: [-1] [ESB] [2017-09-21 14:30:37,785] DEBUG {org.apache.synapse.transport.http.wire} - << "Connection: K

This was a bug in ESB 4.9.0 [1]. This might have fixed in later versions.
Please check whether below property is available in "/repository/conf/passthru-http.properties"
http.headers.preserve=Content-Type
(Note that you can add multiple header values as comma separated list)
Btw use the property "messageType" to set the Content type. Please refer the document on messageType and ContentType from [2]
[1] https://wso2.org/jira/browse/ESBJAVA-4620
[2] https://docs.wso2.com/display/ESB500/Generic+Properties#GenericProperties-messageType

Related

To Merge CSV Files in WSO2 EI 6.6.0 using file connector 2.0.24

I am trying FileMerge Operation in WSO2 EI 6.6.0 using FileConnector 2.0.24.
The problem here is that it is generating an output file with empty content.
API Code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/mergefiles" name="FileMergeAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="********FileMergeAPI" value="Called***********"/>
</log>
<property expression="json-eval($.source)" name="sourceDir" scope="default" type="STRING"/>
<property expression="json-eval($.destination)" name="destDir" scope="default" type="STRING"/>
<property expression="json-eval($.pattern)" name="pattern"/>
<property expression="fn:concat('file:///', $ctx:sourceDir)" name="sourceDir1" scope="default" type="STRING"/>
<property expression="fn:concat('file:///', $ctx:destDir)" name="destDir1" scope="default" type="STRING"/>
<fileconnector.mergeFiles>
<source>{$ctx:sourceDir1}</source>
<destination>{$ctx:destDir1}</destination>
<filePattern>{$ctx:pattern}</filePattern>
</fileconnector.mergeFiles>
<log level="full"/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured"/>
<property expression="get-property('ERROR_MESSAGE')" name="message"/>
<property expression="get-property('ERROR_DETAIL')" name="errordetail"/>
</log>
<send description="Send Error Information"/>
</faultSequence>
</resource>
</api>
Input:
{
"source":"C://Development_Avecto//filemerge//input",
"destination":"C://Development_Avecto//filemerge//output//sample.csv",
"pattern":"//*.csv*"
}
wireLog:
[2022-05-02 13:13:13,417] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "POST /mergefiles HTTP/1.1[\r][\n]"
[2022-05-02 13:13:13,419] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Content-Type: application/json[\r][\n]"
[2022-05-02 13:13:13,422] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "User-Agent: PostmanRuntime/7.29.0[\r][\n]"
[2022-05-02 13:13:13,423] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Accept: */*[\r][\n]"
[2022-05-02 13:13:13,425] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Cache-Control: no-cache[\r][\n]"
[2022-05-02 13:13:13,426] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Postman-Token: dd7b1a25-b87e-4d64-b474-36b13159042a[\r][\n]"
[2022-05-02 13:13:13,427] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Host: 192.168.43.128:8280[\r][\n]"
[2022-05-02 13:13:13,428] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2022-05-02 13:13:13,429] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Connection: keep-alive[\r][\n]"
[2022-05-02 13:13:13,433] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Content-Length: 164[\r][\n]"
[2022-05-02 13:13:13,436] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "[\r][\n]"
[2022-05-02 13:13:13,438] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "{[\r][\n]"
[2022-05-02 13:13:13,438] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "source":"C://Development_Avecto//filemerge//input",[\r][\n]"
[2022-05-02 13:13:13,439] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "destination":"C://Development_Avecto//filemerge//output//sample.csv",[\r][\n]"
[2022-05-02 13:13:13,440] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "pattern":"//*.csv*"[\r][\n]"
[2022-05-02 13:13:13,441] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "}"
[2022-05-02 13:13:13,444] INFO {org.apache.synapse.mediators.builtin.LogMediator} - ********FileMergeAPI = Called***********
[2022-05-02 13:13:13,464] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /mergefiles, MessageID: urn:uuid:90d67ec1-2a3f-4f13-8389-049a24abbdab, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><success>true</success></soapenv:Body></soapenv:Envelope>
[2022-05-02 13:13:13,478] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "HTTP/1.1 202 Accepted[\r][\n]"
[2022-05-02 13:13:13,479] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Date: Mon, 02 May 2022 07:43:13 GMT[\r][\n]"
[2022-05-02 13:13:13,480] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"
[2022-05-02 13:13:13,481] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Connection: keep-alive[\r][\n]"
[2022-05-02 13:13:13,481] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "[\r][\n]"
[2022-05-02 13:13:13,483] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "0[\r][\n]"
[2022-05-02 13:13:13,483] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "[\r][\n]"
if you noticed above wire log i got success response post mergefile operation like below
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><success>true</success></soapenv:Body></soapenv:Envelope>
I already looked this question which doesn't resolve my issue
File 1 content :
File 2 content:
PS: WSO2 EI 6.5.0 also tried the same. getting empty file
What is wrong with the above configuration?

Transport error: 404 Error: Not Found in WSO2 EI 6.1.1

I am trying to send Campaign by using Mailchimp. While calling this endpoint, i am getting ERROR like "Transport error: 404 Error: Not Found". Can anyone please help me out to resolve this?
Note: When i try in Postman by hitting direct mailchimp url it works fine.
Wire Log:
[2020-10-13 11:11:02,611] [] INFO - ApplicationManager Successfully Deployed Carbon Application : QRSagMailchimpIntegrator-CAR_1.0.0 {super-tenant}
[2020-10-13 11:11:14,590] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "POST /campaignSend/predict/sendCampaignId=d164a3989d?AuthKey=3216f54e-b6d9-11e6-80f5-76304dec7eb7 HTTP/1.1[\r][\n]"
[2020-10-13 11:11:14,591] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "User-Agent: PostmanRuntime/7.26.5[\r][\n]"
[2020-10-13 11:11:14,592] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Accept: */*[\r][\n]"
[2020-10-13 11:11:14,594] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Cache-Control: no-cache[\r][\n]"
[2020-10-13 11:11:14,595] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Postman-Token: 5a44668a-6947-4958-ad24-76fef6ddb62e[\r][\n]"
[2020-10-13 11:11:14,597] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Host: localhost:8280[\r][\n]"
[2020-10-13 11:11:14,598] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2020-10-13 11:11:14,599] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Connection: keep-alive[\r][\n]"
[2020-10-13 11:11:14,600] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "Content-Length: 0[\r][\n]"
[2020-10-13 11:11:14,601] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 >> "[\r][\n]"
[2020-10-13 11:11:14,684] [] INFO - LogMediator To: /campaignSend/predict/sendCampaignId=d164a3989d?AuthKey=3216f54e-b6d9-11e6-80f5-76304dec7eb7, MessageID: urn:uuid:aa380541-04f4-4bae-8d8a-d727a7f
a45ba, Direction: request, Welcome Logger = === Send Campaigns ===, Campaign ID = d164a3989d
[2020-10-13 11:11:15,742] [] INFO - HTTPSender Unable to sendViaPost to url[https://us17.api.mailchimp.com/3.0/campaigns/d164a3989d/actions/send/predict/sendCampaignId=d164a3989d?AuthKey=3216f54e-b
6d9-11e6-80f5-76304dec7eb7]
org.apache.axis2.AxisFault: Transport error: 404 Error: Not Found
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:326)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:196)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:302)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:211)
at org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:150)
at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:113)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:343)
at org.apache.synapse.rest.API.process(API.java:399)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:78)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:326)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:372)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
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)
[2020-10-13 11:11:15,778] [] INFO - LogMediator To: https://us17.api.mailchimp.com/3.0/campaigns/d164a3989d/actions/send/, MessageID: urn:uuid:aa380541-04f4-4bae-8d8a-d727a7fa45ba, Direction: reque
st, FAUALTYYYYYYYYYYYYYYYYYY************* = Transport error: 404 Error: Not Found
[2020-10-13 11:11:15,781] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "HTTP/1.1 202 Accepted[\r][\n]"
[2020-10-13 11:11:15,782] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "Date: Tue, 13 Oct 2020 05:41:15 GMT[\r][\n]"
[2020-10-13 11:11:15,783] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"
[2020-10-13 11:11:15,784] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "Connection: keep-alive[\r][\n]"
[2020-10-13 11:11:15,785] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "[\r][\n]"
[2020-10-13 11:11:15,785] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "0[\r][\n]"
[2020-10-13 11:11:15,786] [] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "[\r][\n]"
Postman: (Direct Mailchimp URL)
Mailchimp URL
API Code:
<api context="/campaignSend" name="campaign_send_v1" xmlns="http://ws.apache.org/ns/synapse">
<resource method="POST" uri-template="/predict/sendCampaignId={campaignId}?AuthKey={secKey}">
<inSequence>
<log>
<property name="Welcome Logger" value="=== Send Campaigns ==="/>
<property expression="get-property('uri.var.campaignId')" name="Campaign ID"/>
</log>
<property description="secKey" expression="get-property('uri.var.secKey')" name="secKey" scope="default" type="STRING"/>
<property description="ESB-Authentication" expression="get-property('QRSag-VBFeedsAuthKey')" name="authKey" scope="default" type="OM"/>
<property description="FeedsStoredAuthKey" expression="$ctx:authKey//*[local-name()='SecurityToken']" name="authenticatekey" scope="default" type="STRING"/>
<!-- ==================== Check authentication ==================== -->
<filter description="CheckUserAPIValidation" xpath="get-property('secKey') = get-property('authenticatekey')">
<then/>
<else>
<payloadFactory media-type="json">
<format>{"errorCode":"$1","errorTrace":"$2"}</format>
<args>
<arg value="QRSaG - 401"/>
<arg value="Invalid Authentication.Contact QRSagSupport"/>
</args>
</payloadFactory>
<log level="custom">
<property expression="json-eval($.)" name="===API Authentication Failed==="/>
</log>
<respond/>
</else>
</filter>
<property name="Authorization" scope="transport" type="STRING" value="Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
<call blocking="true">
<endpoint key="sendCampaign"/>
<timeout>
<duration>17000000</duration>
<responseAction>fault</responseAction>
</timeout>
</call>
<log>
<property expression="json-eval($.)" name="LoggerText_JsonResponse"/>
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence>
<log>
<property expression="get-property('ERROR_MESSAGE')" name="FAUALTYYYYYYYYYYYYYYYYYY*************"/>
</log>
</faultSequence>
</resource>
Endpoint Value:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="sendCampaign" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="https://us17.api.mailchimp.com/3.0/campaigns/{uri.var.campaignId}/actions/send/"/>
</endpoint>
Analyzing the provided information we can observe that for the postman request you are invoking the URL
https://us17.api.mailchimp.com/3.0/campaigns/d164a3989d/actions/send
But from the ESB server, you are invoking the following URL
https://us17.api.mailchimp.com/3.0/campaigns/d164a3989d/actions/send/predict/sendCampaignId=d164a3989d?AuthKey=3216f54e-b
6d9-11e6-80f5-76304dec7eb7
This is because the context path is appended for the backend call. You can remove this by adding the following property before the call mediator.
<property name="REST_URL_POSTFIX" action="remove" scope="axis2"/>

Soap Header is removed in payload factory in wso2 esb

I am using WSO2 Payload factory to create one soap request in which some information is sent to third party. This payload removes my soap header value. Can anyone please help me out in this. I can see only body is being passed and header is getting removed.
I have to use below request to get some token
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oas="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:sec="http://schemas.cdi.ltsa.govt.nz/SecurityService.xsd" xmlns:sec1="http://schemas.cdi.ltsa.govt.nz/SecurityService" xmlns:oas1="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:acc="http://schemas.cdi.ltsa.govt.nz/Security/AccessControl/" xmlns:sec2="http://localhost/Schema/SecurityService">
<soapenv:Header>
<oas:Security>
<oas:UserNameToken>
<oas:UserName>XXXX</oas:UserName>
<oas:Password>XXXX</oas:Password>
</oas:UserNameToken>
</oas:Security>
</soapenv:Header>
<soapenv:Body>
<acc:AuthenticateClient>
<sec2:AuthenticateClientRequest>
<sec2:RequestBody></sec2:RequestBody>
</sec2:AuthenticateClientRequest>
</acc:AuthenticateClient>
</soapenv:Body>
</soapenv:Envelope>
<header name="SOAPAction" scope="transport" value="http://schemas.cdi.ltsa.govt.nz/Security/AccessControl/AuthenticateClient"/>
<script language="js"><![CDATA[var envelope = mc.getEnvelopeXML();
var oas = new Namespace('http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd');
mc.addHeader(false, <oas:Security xmlns:oas="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<oas:UserNameToken>
<oas:UserName>XXXX</oas:UserName>
<oas:Password>XXXX</oas:Password>
</oas:UserNameToken>
</oas:Security>
);]]></script>
<payloadFactory media-type="xml">
<format>
<Body>
<AuthenticateClient>
<AuthenticateClientRequest>
<RequestBody/>
</AuthenticateClientRequest>
</AuthenticateClient>
</Body>
</format>
<args>
<arg evaluator="xml" expression="$ctx:UserName" xmlns:ns="http://org.apache.synapse/xsd"/>
<arg evaluator="xml" expression="$ctx:Password" xmlns:ns="http://org.apache.synapse/xsd"/>
</args>
</payloadFactory>
<log level="full"/>
<call>
<endpoint>
<address trace="disable" uri="http://XXXX:28080/services/XXXX"/>
</endpoint>
</call>
<respond/>
Logs:
wire << "POST /services/B2BProxyVechicle HTTP/1.1[\r][\n]"
[2017-09-18 16:38:12,230] DEBUG - wire << "SOAPAction: http://XXXXX/AccessControl/AuthenticateClient[\r][\n]"
[2017-09-18 16:38:12,225] DEBUG - SequenceMediator End : Sequence key=<Value {name ='null', keyValue ='PPSR_VehicleInfo_IN_SEQ'}>
[2017-09-18 16:38:12,245] DEBUG - SequenceMediator End : Sequence <anonymous>
[2017-09-18 16:38:12,238] DEBUG - wire << "Accept-Encoding: gzip,deflate[\r][\n]"
[2017-09-18 16:38:12,253] DEBUG - wire << "Content-Type: text/xml; charset=UTF-8[\r][\n]"
[2017-09-18 16:38:12,257] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2017-09-18 16:38:12,261] DEBUG - wire << "Host: 1r][\n]"
[2017-09-18 16:38:12,265] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2017-09-18 16:38:12,268] DEBUG - wire << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2017-09-18 16:38:12,273] DEBUG - wire << "[\r][\n]"
[2017-09-18 16:38:12,275] DEBUG - wire << "a3[\r][\n]"
[2017-09-18 16:38:12,278] DEBUG - wire << "<Body xmlns="http://ws.apache.org/ns/synapse"><AuthenticateClient><AuthenticateClientRequest><RequestBody/></AuthenticateClientRequest></AuthenticateClient></Body>[\r][\n]"
[2017-09-18 16:38:12,292] DEBUG - wire << "0[\r][\n]"
[2017-09-18 16:38:12,294] DEBUG - wire << "[\r][\n]"
[2017-09-18 16:38:12,305] DEBUG - wire >> "HTTP/1.1 200 OK[\r][\n]"
[2017-09-18 16:38:12,309] DEBUG - wire >> "Host: 3[\r][\n]"
[2017-09-18 16:38:12,313] DEBUG - wire >> "SOAPAction: "http://XXXXXX/AccessControl/AuthenticateClient"[\r][\n]"
[2017-09-18 16:38:12,321] DEBUG - wire >> "Accept-Encoding: gzip,deflate[\r][\n]"
[2017-09-18 16:38:12,325] DEBUG - wire >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
[2017-09-18 16:38:12,330] DEBUG - wire >> "Date: Mon, 18 Sep 2017 04:38:12 GMT[\r][\n]"
[2017-09-18 16:38:12,334] DEBUG - wire >> "Transfer-Encoding: chunked[\r][\n]"
[2017-09-18 16:38:12,337] DEBUG - wire >> "Connection: Keep-Alive[\r][\n]"
[2017-09-18 16:38:12,341] DEBUG - wire >> "[\r][\n]"
[2017-09-18 16:38:12,343] DEBUG - wire >> "94[\r][\n]"
[2017-09-18 16:38:12,346] DEBUG - wire >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>[\r][\n]"
[2017-09-18 16:38:12,360] DEBUG - wire >> "0[\r][\n]"
[2017-09-18 16:38:12,362] DEBUG - wire >> "[\r][\n]"
[2017-09-18 16:38:12,364] DEBUG - SynapseCallbackReceiver Callback removed for request message id : urn. Pending callbacks count : 0
[2017-09-18 16:38:12,375] DEBUG - SynapseCallbackReceiver Synapse received an asynchronous response message
Try to add the following properties.
<property name="PRESERVE_WS_ADDRESSING" value="true"/>
<property name="preserveProcessedHeaders" value="true" scope="default"/>
You can also add custom headers, like described here.
https://docs.wso2.com/display/ESB490/Custom+SOAP+Headers

API Manager - Send Mediator: "Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool} java.lang.NumberFormatException: null"

I have 2 API as below and I am trying to invoke API2 from my API1 using SEND mediator but no response is returned and error is printed in logs:
API1 -
URLhttps://localhost:8243/sendtest/1.0/{num}
In Flow Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="send_mediator_test_in" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="get-property('uri.var.num')" name="uri.var.num" scope="default" type="STRING"/>
<send>
<endpoint>
<http method="get" uri-template="https://localhost:8243/protest/1.0/{uri.var.num}"/>
</endpoint>
</send>
</sequence>
API2 - (Prototyped)
URLhttps://localhost:8243/protest/1.0/{num}
Inline Script
mc.setProperty('CONTENT_TYPE', 'application/json');
var Num = mc.getProperty('uri.var.num');
mc.setPayloadJSON({ "NumberReturn": Num });
Response
{
"NumberReturn": "100"
}
Invoking API1 with below environments works fine and proper response is returned.
OS: Windows 7
Java: 1.7.0_45
WSO2 AM: 2.0.0
But gets error with below environment
OS: Red Hat Enterprise Linux Server release 6.8 (Santiago)
Java: 1.7.0_101
WSO2 AM: 2.0.0
Error while invoking API1
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "a4[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "0[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1] [] [2017-02-03 06:34:23,265] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-2 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [-1234] [] [2017-02-03 06:34:23,278] ERROR {org.apache.axis2.transport.base.threads.NativeWorkerPool} - Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool}
java.lang.NumberFormatException: null
at java.lang.Long.parseLong(Long.java:404)
at java.lang.Long.parseLong(Long.java:483)
at org.wso2.carbon.apimgt.gateway.handlers.common.APIMgtLatencyStatsHandler.handleResponse(APIMgtLatencyStatsHandler.java:43)
at org.apache.synapse.rest.API.process(API.java:323)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:56)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:300)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:255)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.server.handler.ChannelCloseHandler} - Received channel close for id 1 citing class 0 and method 0 {org.wso2.andes.server.handler.ChannelCloseHandler}
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.server.AMQChannel} - No consumers to unsubscribe on channel [/127.0.0.1:53226(admin):1] {org.wso2.andes.server.AMQChannel}
TID: [-1234] [] [2017-02-03 06:34:30,750] INFO {org.wso2.andes.kernel.FlowControlManager} - Channel removed (ID: 127.0.0.1:53226) {org.wso2.andes.kernel.FlowControlManager}
TID: [-1234] [] [2017-02-03 06:34:30,752] INFO {org.wso2.andes.server.handler.ConnectionCloseMethodHandler} - ConnectionClose received with reply code/reply text 200/JMS client is closing the connection. for /127.0.0.1:53226(admin) {org.wso2.andes.server.handler.ConnectionCloseMethodHandler}
Please advise what is wrong.
This is a known issue in APIM 2.0.0 and is fixed in 2.1.0
This happens with prototype APIs or other APIs which does not have APIAuthenticationHandler, when you have analytics enabled. Maybe you have enable analytics in your Windows setup only.
As a workaround, put
<property expression="get-property('SYSTEM_TIME')" name="api.ut.backendRequestTime"/>
inside inSequence of your prototype API, like this.
<inSequence>
<script language="js">your-js-goes-here</script>
<property expression="get-property('SYSTEM_TIME')" name="api.ut.backendRequestTime"/>
...
...
<inSequence>

WSO2 Proxy Service "InSequence" incorrectly sending a request instead of a response for API

I am experiencing an issue within my In Sequnce of the following proxy :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="AckServiceAPIProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="json-xml" value="text/xml" scope="axis2" type="STRING"/>
<log level="full" category="DEBUG" separator="____:____"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="name"
expression="//productSearch/productName/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="size"
expression="//productSearch/productSize/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="colour"
expression="//productSearch/productColour/text()"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ack="http://ack.pepkor.org">
<soap:Header/>
<soap:Body>
<ack:productSearch>
<ack:productName>$1</ack:productName>
<ack:productSize>$2</ack:productSize>
<ack:productColour>$3</ack:productColour>
</ack:productSearch>
</soap:Body>
</soap:Envelope>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd"
expression="$ctx:name"
evaluator="xml"/>
<arg xmlns:ns="http://org.apache.synapse/xsd"
expression="$ctx:size"
evaluator="xml"/>
<arg xmlns:ns="http://org.apache.synapse/xsd"
expression="$ctx:colour"
evaluator="xml"/>
</args>
</payloadFactory>
<log level="full" category="DEBUG" separator="____:____"/>
<send>
<endpoint key="conf:/ackServiceEpr"/>
</send>
</inSequence>
<outSequence>
<log level="full" category="DEBUG" separator="____:____"/>
<property name="messageType"
value="application/json"
scope="axis2"
type="STRING"/>
<log level="full" category="DEBUG" separator="____:____"/>
<send/>
</outSequence>
<faultSequence/>
</target>
<description/>
</proxy>
The REST request :
{ "productSearch":
{ "productName": "nike_shirts" ,
"productSize": "7",
"productColour": "red"
}
}
Let me break down the log :
TID: [0] [ESB] [2015-02-03 11:56:14,994] DEBUG {org.apache.synapse.commons.json.JsonStreamBuilder} - #processDocument. Built JSON payload from JSON stream. MessageID: urn:uuid:0d62c4ad-01b5-4eb5-ae7e-3b3aee762fbf {org.apache.synapse.commons.json.JsonStreamBuilder}
...
#mediate. Transformed payload format>>>
<pfPadding>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ack="http://ack.pepkor.org"><soap:Header></soap:Header><soap:Body><ack:productSearch><ack:productName>nike_shirts</ack:productName><ack:productSize>7</ack:productSize><ack:productColour>red</ack:productColour></ack:productSearch></soap:Body></soap:Envelope></pfPadding>
So I would expect the above message to be sent to the Ack Service (on Application Server) , however , INSIDE the SEND mediator , it then tranforms the original request payload(REST) again , and instead sends this to the service :
<productSearch><productName>nike_shirts</productName><productSize>7</productSize><productColour>red</productColour></productSearch>
The service call fails because of no namespaces , and brings back a fault.
The send mediator full log :
Start : Send mediator {org.apache.synapse.mediators.builtin.SendMediator}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.EndpointContext} - Checking if endpoint : AnonymousEndpoint currently at state ACTIVE can be used now? {org.apache.synapse.endpoints.EndpointContext}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - Sending message through endpoint : null resolving to address = https://localhost:9444/services/ProductSearchACKService.ProductSearchACKServiceHttpsSoap12Endpoint/ {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,896] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - SOAPAction: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,897] DEBUG {org.apache.synapse.endpoints.AddressEndpoint} - WSA-Action: null {org.apache.synapse.endpoints.AddressEndpoint}
TID: [0] [ESB] [2015-02-03 12:08:34,897] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} - Sending [add = false] [sec = false] [rm = false] [mtom = false] [swa = false] [format = null] [force soap11=false] [force soap12=false] [pox=false] [get=false] [encoding=null] [to=https://localhost:9444/services/ProductSearchACKService.ProductSearchACKServiceHttpsSoap12Endpoint/] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [0] [ESB] [2015-02-03 12:08:34,898] DEBUG {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient} - Message [Original Request Message ID : urn:uuid:a451c7d8-b5a9-4474-8bd3-af9a25b65933] [New Cloned Request Message ID : urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491] {org.apache.synapse.core.axis2.Axis2FlexibleMEPClient}
TID: [0] [ESB] [2015-02-03 12:08:34,898] DEBUG {org.apache.synapse.core.axis2.SynapseCallbackReceiver} - Callback added. Total callbacks waiting for : 1 {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2015-02-03 12:08:34,900] DEBUG {org.apache.synapse.commons.json.JsonUtil} - #transformElement. Transformed OMElement. Result: <productSearch><productName>nike_shirts</productName><productSize>7</productSize><productColour>red</productColour></productSearch> {org.apache.synapse.commons.json.JsonUtil}
TID: [0] [ESB] [2015-02-03 12:08:34,901] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #XmlReaderDelegate. Setting XMLStreamReader: com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,902] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productSearch, new=productSearch {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,903] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productName, new=productName {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,903] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productName, new=productName {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productSize, new=productSize {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productSize, new=productSize {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,904] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productColour, new=productColour {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productColour, new=productColour {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.XmlReaderDelegate} - #getLocalName. old=productSearch, new=productSearch {org.apache.synapse.commons.json.XmlReaderDelegate}
TID: [0] [ESB] [2015-02-03 12:08:34,905] DEBUG {org.apache.synapse.commons.json.JsonStreamFormatter} - #writeTo. Wrote JSON payload to output stream. MessageID: urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491 {org.apache.synapse.commons.json.JsonStreamFormatter}
TID: [0] [ESB] [2015-02-03 12:08:34,906] DEBUG {org.apache.synapse.mediators.builtin.SendMediator} - End : Send mediator
.
Your proxy receive a JSON request and you don't specify anything for the output so, the ESB send a JSON request to your ack service (see log trace #writeTo. Wrote JSON payload to output stream. MessageID: urn:uuid:b0540f15-2094-4c3e-9184-fdc2df2fd491 {org.apache.synapse.commons.json.JsonStreamFormatter})
If you want to send a SOAP request, you can specify attribute format="soap11" in your endpoint def (ackServiceEpr) or add a property in your inSequence, before send :
<property name="messageType" value="text/xml" scope="axis2"/>
Perhaps do you need to set the SOAPAction in this case, use header mediator. If you want to set a blank one :
<header name="Action" value=""""/>
If your ack service need plain xml, use application/xml