I have a situation here where as I need to create a API flow such as below.
I manage to create an API using the GET method and Call Mediator for the login request. However, when i change the API method to POST (because I need to send something in the body) and using Call Mediator for the Login request, it prompt me an error.
I am not sure whether POST method API is not allowed to be using together with the Call Mediator or not.
Is the flow I want to create above, is achievable just using API or do i need to create a Business Process Management Project?
If I wanna use POST method together with Send Mediator, how would it be ? I was aware that I can not put any mediator after the Send Mediator
Any advice would be grateful. Thank you again.
What is the error that you got? and Try removing REST_URL_POSTFIX property before calling to your endpoint.
<property name="REST_URL_POSTFIX" action="remove" scope="axis2"/>
Related
I am new to WSO2 and I have some questions.
I have an api and when consumption returns an XML response, I need it in JSON, from what I have read I must modify the "Response content type" but I don't know how
Where can I find documentation to call the token generator api and my api through postman.
Finally, some documentation of how the APIs are consumed from my final application
thank you very much
I have an api and when consumption returns an XML response, I need it in JSON, from what I have read I must modify the "Response content type" but I don't know how
You have to set the messageType as application/json in the out sequence.
<property name="messageType" value="application/json" scope="axis2"/>
You can refer this for more details https://docs.wso2.com/display/EI640/Working+with+JSON+Message+Payloads
And also please check this https://docs.wso2.com/display/AM260/Adding+Mediation+Extensions to know how to add mediation extension for as out sequence in API manager
Where can I find documentation to call the token generator api and my api through postman.
Refer this https://apim.docs.wso2.com/en/latest/learn/api-security/oauth2/grant-types/overview/
Select your grant type and analyse it.
Finally, some documentation of how the APIs are consumed from my final application
This may help you https://apim.docs.wso2.com/en/3.1.0/learn/consume-api/manage-subscription/subscribe-to-an-api/
Scenario
I have configured the API in WSO2 which connects to my back-end HTTP service.
Before calling my back-end service, I want to call another HTTP end point (XML over HTTP) to perform some validations. If the validation response is success then the back end point configured in the API gateway can be invoked else the API needs to return error. Please let me know how this can be achieved.
Thanks,
Karthi
You can add a custom in sequence in your API https://docs.wso2.com/display/AM260/Adding+Mediation+Extensions and handle that particular logic there.
In the In sequence, you can add a call mediator https://docs.wso2.com/display/EI660/Call+Mediator to call the Back end and following that you may add a filter mediator https://docs.wso2.com/display/EI660/Filter+Mediator and validate the response and proceed the mediation flow based on it.
In the filter mediator, you may implement a logic to respond back from there itself if it is an error else do nothing so that it will proceed and call you API back end.
I am working on WSO2 ESB 4.9.0. We have an API with in and out sequences. All the business logic is there in, in sequence and out sequence doesn't have any logic implemented. Some times we need to exit the flow from in sequence because all our back end service calls are made with call mediator and not with send mediator. In this service chain pattern, if we want to exit the flow, do we need to use respond OR loopback mediator.
Can somebody help me what are the basic use cases where loopback and respond can be used
respond mediator will send back the response to the client. loopback mediator will move the message flow to the outsequence. In this case you need to use respond mediator since you need to exit the flow and respond to the client. However, if you have any mediation that you need to execute in outsequence, you can always use loopback mediator and use respond mediator in the outsequence to do the same.
Is there any way in WSO2 API Manger, to read a parameter value from the request xml/json (payload) and based on that value, route the request to different backend endpoints?
You can try using mediator extensions.
The API Manager has a default mediation flow for the API invocation requests that it receives. You can extend this default mediation flow to route the request.
First write a sequence file to change the flow. Sample sequence as
follows.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="YahooWeather2">
<property name="YQL"
type="Expression"
expression="concat('?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22',syn:get-property('uri.var.zipcode'),',',syn:get-property('uri.var.country'),'%22)format=json')"/>
<property name="REST_URL_POSTFIX" type="Expression" expression="get-property('YQL')" scope="Axis2"/>
</sequence>
To upload the sequence file to APIM, login as admin go to main->
Resources-> Browse
Go to /_system/governance/apimgt/customsequences/in. from the
tree view
Click on Add Resource upload the sequence file you created.
Login to API Publisher ,select the api and click on edit and go
to Manage tab.
Click on check box for Check to select a custom sequence to be
executed in the message flow and in the In Flow dropdown
select your sequence(in sample case YahooWeather2) and do
Save & Publish .
Login to API store and subscribe the api and generate an access
token.
You can check availability from API Console in API store. for ferther details refer https://docs.wso2.com/display/AM191/Change+the+Default+Mediation+Flow+of+API+Requests
I am facing an alarming situation with the services published in WSO2 ESB. In an absolutely random way, some services fail the response message validation, in spite of the fact that de response is totally correct. The error deals with missed tagges in the payload. This takes place with no pattern at all. A services is working until it starts to respond a validation fault. When this occurs, I check the following:
A soapUI client can be generated by the WSDL published by the ESB, so it is not a reference issue.
Response is validated successfully by the XSD used by the validate mediator. (validated by an alternative tool).
I can even see the payload that previously is logged and it is correct. This have occured several times in different services.
The only way to fix this is undeploy the services and deploy it again. I have try the redeploy option in the service dashboard, and reset the whole system with no success.
I have a feeling that somehow the payload used by the validate mediator is a kind of locked, blank, unreachable or dirty.
How can I set the validate mediator process in debug mode? I think this might help.
Any help? I am thinking of denying using this system in a production environment.
I use wso2 esb 4.5.1.
King regards.
Put the log mediator with the log level ="full" before the validate mediator and see, what is passed to the validate mediator. This will help you to find the erroneous response..