Mediation of Class Mediator not happening - api

I am hitting my api from another service with help of endpoint in Wso2. However, I am getting the error below:
"errorCode": "0",
"errorMessage": "Error occured in the mediation of the class mediator"
Note: The error comes only for one endpoint rest all is working absolutely fine for the same service. Unable to figure out the problem.
for further detail of error I am attaching it below:
"errorDetail": "org.apache.synapse.SynapseException: Error occured in the mediation of the class mediator\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:102)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)\n\tat
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)\n\tat
org.apache.synapse.api.Resource.process(Resource.java:342)\n\tat
org.apache.synapse.api.API.process(API.java:463)\n\tat
org.apache.synapse.api.AbstractApiHandler.apiProcess(AbstractApiHandler.java:93)\n\tat
org.apache.synapse.api.AbstractApiHandler.dispatchToAPI(AbstractApiHandler.java:71)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.dispatchToAPI(RestRequestHandler.java:84)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.process(RestRequestHandler.java:70)\n\tat
org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:54)\n\tat
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:344)\n\tat
org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:101)\n\tat
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:375)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:434)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:182)\n\tat
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat
java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: org.apache.synapse.SynapseException:
org.json.simple.parser.ParseException\n\tat
org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:376)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:139)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.updateInstancePropertiesAndMediate(ClassMediator.java:178)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:97)\n\t... 20
more\nCaused by: Unexpected character (<) at position 0.\n\tat
org.json.simple.parser.Yylex.yylex(Yylex.java:610)\n\tat
org.json.simple.parser.JSONParser.nextToken(JSONParser.java:269)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:118)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:81)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:75)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:44)\n\
t... 22 more\n"

It seems your client is sending an XML request body to an API that expects a JSON message, or sending the wrong Content-Type header.

Related

Error propagation from system to process to experience APIs in Mule 4

The system API throws an error - ERROR:TYPE_1 with status code 401.
The process API should give the same error.
The experience API should give the same error.
How can this be achieved?
In the the process API you can write something like this
<flow name="error_flow">
<raise-error doc:name="raise-error" type="ERROR:TYPE_1" description="401 error ocurred">
<error-handler>
<on-error-continue enableNotification="true" type="ERROR:TYPE_1" doc:name ="on error continue" doc:id="on-error-continue">
// here you can write a dwl which gives you a payload like
// {
"errorCode" : 401
"errorType" : "ERROR:TYPE_1"
}
<on-error-continue>
</error-handler>
This payload will reach to your experience layer.

api implementation - is this the right approach ? ( Mule 4.4 )

I am implementing a GET request which needs to interact with an ERP and extract employee details .
Now the interaction with ERP is not using HTTP so it does not return status codes such as 400 etc
Any error if present is returned in the XML payload response .
Example:
<?xml version="1.0" encoding="utf8" ?>
<Output>
<Error>
<Status>0</Status>
<Details>No errors</Details>
</Error>
</Output>
So I have implemented it this way - where after calling ERP and receiving response I check if response contains any error ( errorCode = 0 means an error otherwise all good )
If not an error normal processing , if an error I simply set the http status to 400 and populate response with error details.
Question:
In the error flow I am NOT throwing any exception / error and simply returning a response with 400 response status and error details .
My gut feel is in this case there is no need to Raise error ( throw ) and then again catch it in error handler.
I thought it is unnecessary in this case but was looking for some feedback ?
Note - the exception handler below is meant to catch errors such as ERP is down / unavailable etc
Note - as this is more a design / approach question , am only pasting screen print of the flow and not the actual code
Please do share your feedback and suggestions
There is no mandate to use Mule Error handling to return an HTTP status, if that's your question.
Note that Mule 4 uses error handling, not exception handling, though it looks similar.
Unrelated, it is strange that you are using HTTP status 400 for a server error, when 400 is meant for bad client request. You may want to use a more proper status.

WSO2 API Manager returning RunTime Error

I have an API in WSO2. When I try to test it in the store with valid parameters via GET, it returns the following error message:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>101504</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Send timeout</am:description>
</am:fault>
I have already searched and tried a lot, but with no success, always returning the same error. Don't know if helps, but the api that I try to access is a PHP file.
Any ideas?
EDIT:
I have identical apis to this one, changing only the response, that are working properly. Even if I erase the php file that the API is pointing, the error keep coming.
EDIT:
I changed the code in Management Console, in Metadata>List>APIs:
{"production_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"sandbox_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"implementation_status":"managed","endpoint_type":"http"}
to this:
{"production_endpoints":
{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"sandbox_endpoints":{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"implementation_status":"managed","endpoint_type":"http"}
And this error message vanishes. But this new one appears:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>303001</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Currently , Address endpoint : [ Name : admin--myapi_APIproductionEndpoint_0 ] [ State : SUSPENDED ]</am:description>
EDIT: this error message is appearing just sometimes. Most of the time the request takes long time to run and then returns nothing( no content )
Any ideas how to solve it?

Unable to retrieve header field SenderCompID , 142 from de-serialized Quickfixj Quote messase

Our FIX Engine implemented in QuickfixJ send the received quote message in the quote session to another application listening on JMS queue for further processing like persistig to DB.
The message serialized and de-serialized using Apache serializationUtils.
The problem is, the application throws FieldNotFound error when it attempts to retrieve SenderCompId header field from the de-serialized message.
setSenderlocid(header.getField(new SenderLocationID()).toString())
quickfix.FieldNotFound: Field [142] was not found in message.
at quickfix.FieldMap.getField(FieldMap.java:216)
at quickfix.FieldMap.getFieldInternal(FieldMap.java:353)
at quickfix.FieldMap.getField(FieldMap.java:349)
Does serialization work with QuickFixJ messages?

Yodlee executeUserSearchRequest error

I try to get information from Yodlee API.
I have a test user where I've implemented adding an account and I got refresh OK from the site:
{ siteRefreshStatus: {
siteRefreshStatusId: 8
siteRefreshStatus: "REFRESH_COMPLETED_WITH_UNCERTAIN_ACCOUNT"
}
- siteRefreshMode: {
refreshModeId: 2
refreshMode: "NORMAL"
}
- updateInitTime: 0
nextUpdate: 1391603301
code: 403
noOfRetry: 0
}
}
Now when I try to perform search and get the actual transactions I get this error:
{
errorOccured: "true"
exceptionType: "com.yodlee.core.IllegalArgumentValueException"
refrenceCode: "_57c250a9-71e8-4d4b-830d-0f51a4811516"
message: "Invalid argument value: Container type cannot be null"
}
The problem is that I have container type!
Check out the parameters I send:
cobSessionToken=08062013_2%3Ad02590d4474591e507129bf6baaa58e81cd9eaacb5753e9441cd0b1ca3b8bd00a3e6b6a943956e947458307c1bb94b505e2eb4398f890040a3db8c98606c0392&userSessionToken=08062013_0%3A8e8ef9dd4f294e0f16dedf98c1794b96bf33f2e1f2686eda2f35dfe4901dd3a871eed6d08ce52c99a74deb004c025ebf4bf94c7b17baf8ba18aacb331588f5f5&transactionSearchRequest.containerType=bank&transactionSearchRequest.higherFetchLimit=1000&transactionSearchRequest.lowerFetchLimit=1&transactionSearchRequest.resultRange.endNumber=500&transactionSearchRequest.resultRange.startNumber=1&transactionSearchRequest.searchClients.clientId=1&transactionSearchRequest.searchClients.clientName=DataSearchService&transactionSearchRequest.ignoreUserInput=true&transactionSearchRequest.searchFilter.currencyCode=USD&transactionSearchRequest.searchFilter.postDateRange.fromDate=01-01-2014&transactionSearchRequest.searchFilter.postDateRange.toDate=01-31-2014&transactionSearchRequest.searchFilter+.transactionSplitType=ALL_TRANSACTION&transactionSearchRequest.searchFilter.itemAccountId+.identifier=10008425&transactionSearchRequest.searchClients=DEFAULT_SERVICE_CLIENT
There is an error occurred while adding the account, which can be interpreted by this parameter code: 403 and hence you will not be seeing that account when you call the getItemSummary API. An account is successfully linked if the code has zero as value. E.g.code:0 . 403 is an error which is show if Yodlee's data agent has encountered an unhandled use case. Hence for any such error you should file a service request using Yodlee customer care tool.
To know more about error codes please visit -
https://developer.yodlee.com/FAQs/Error_Codes
The status is show as completedsiteRefreshStatus: "REFRESH_COMPLETED_WITH_UNCERTAIN_ACCOUNT"because addition of any account is followed by a refresh in which Yodlee's data agent logs into the websites of FIs and try scraping data. Hence completion of this activity is denoted as REFRESH_COMPLETED even when there is an error occurred.
TranasctionSearch issue -
I can see two of the parameters with a "+" sign. Since transactionSlipttype and containerType are dependent on each other the error is thrown.
&transactionSearchRequest.searchFilter+.transactionSplitType=ALL_TRANSACTION
&transactionSearchRequest.searchFilter.itemAccountId+.identifier=10008425
The right parameters are -
&transactionSearchRequest.searchFilter.transactionSplitType=ALL_TRANSACTION
&transactionSearchRequest.searchFilter.itemAccountId.identifier=10008425