WSO2 api manager not showing destination adress in API Usage by Destination - wso2

I'm using WSO2 AM 2.0.
I'm using dynamic endpoint throught custom sequence.
The problem is that my endpoint destination adress is not showing now
I have verifyed that it is insert empty in my analytics DB.
Is there any way to add this information?

In your custom sequence, please set another property named "ENDPOINT_ADDRESS" with the same value as the one you assign to "To" header. It will solve your problem.
For consequent invokes, the destination address will be set correctly.
ex:
<header name="To" value="https://localhost:9448/am/sample/pizzashack/v1/api/menu"/>
<property name="ENDPOINT_ADDRESS" value="https://localhost:9448/am/sample/pizzashack/v1/api/menu"/>

Related

How to read data from properties file in wso2 esb

I created one file test.properties in the //wso2esb-4.9.0/repository/conf folder.
In this test.properties files I created on properties given below
testData=welcome
Now, I want to read that testData value in the proxy files in WSO2.
Here is a proxy code to get the value:
<property name="irisprop" expression="get-property('registry','conf:/iris.properties#tokenvalue')" scope="default"/>
The get-property('registry','') will fetch the values stored in the registry 1. You can refer to the documentation on 2, [3] to further clarification regarding the registry. You can use the carbon console to browse and add the registry resources.
You will not be able to read a file content directly with the property mediator. But if your use case is to use the file system to store data, you will need to use the VFS transport or the file connector. Please refer to the documentation [4], [5] to further clarify this.
1-https://docs.wso2.com/display/EI6xx/Property+Mediator#PropertyMediator-Example4:ReadingafilestoredintheRegistry
2-https://docs.wso2.com/display/ESB490/Working+with+the+Registry
[3]-https://docs.wso2.com/display/ESB490/Managing+Registry+Content
[4]-https://docs.wso2.com/display/EI6xx/VFS+Transport
[5]-https://docs.wso2.com/display/ESBCONNECTORS/File+Connector

Generate/Create New Query Parameter in WSO2-AM Sequence

I have a use case where create new set of query parameters(Say 4 new query parms) based on a query parameter come from request and send all query parameters(both newly created and old) into target server. How to achieve ? I have created a logic to split that query param come from request using Script Mediator and set into query param function like mc.setProperty("query.param.IndA", IndA);
<script function="restGET"
key="conf:repository/resources/scripts/rest.js" language="js"/>
<header name="To" scope="default" value="http://localhost:8443/res/c/r/cust/0.0.1/e"/>
But this doesn't set in request and reached to end server. Is that anyway better way than this approach ?
You can use REST_URL_POSTFIX property to append values to the target endpoint. Please refer the example which uses that property.
Answer given by #pubci is correct. Here I am adding some additional info on reading query parameter from request- To read the query parameter from the request no need to have script mediator , you can just use synapse xpath variable $url [1]. You can find a sample here[2]
[1] https://docs.wso2.com/display/ESB481/Synapse+XPath+Variables#SynapseXPathVariables-$trp
[2] https://jenananthan.wordpress.com/2015/09/22/how-to-read-dynamic-query-parameter-in-esbapim-synapse/

wso2 api manager path pattern issue

I'm having issue with what I feel is a simple url pattern match, but seeing unexpected behavior for an API I created.
I set up the API, and when I place the "URL Pattern", I do something simple like "/player/{playerId}"
When I go to the next screen to input the endpoint information, I reference my path variable as it appears in the documentation, like http://mycoolendpoint.com/playerInfo/{uri.var.playerId}
What I end up seeing is that the entire URL pattern is being appended to my endpoint. So, in the above, instead of seeing the expected http://mycoolendpoint.com/playerInfo/111, I see coming across the wire http://mycoolendpoint.com/playerInfo/111/player/111
Am I setting up something wrong when I do this syntax that it's appending the entire URL pattern to the Sandbox and Production endpoints instead of just the value of the path variable?
API's resource is normally appended to its endpoint URL by API Manager by default So to avoid this you can follow below instructions,
Create a custom sequence with the following content and save it as a .xml file.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSequence">
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
</sequence>
Now edit your API in publisher. In design view go to "Message Mediation Policies" section and Enable Message mediation. Now add a In Flow and upload the previously saved sequence.
There are 2 ways you can do this by defining your API like below.
1) Define resource like this.
playerInfo/{playerId}
and define endpoint like this.
http://mycoolendpoint.com/
Or
2) Define resource like this.
/{playerId}
and define endpoint like this.
http://mycoolendpoint.com/playerInfo/
Or you can also do this as #ycr has mentioned. If you want to do that change for all APIs without creating a custom sequence file, you can add below line inside InSequence section of <APIM_HOME>/repository/resources/api_templates/velocity_template.xml file.
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
This template is used when APIM creates synapse files of new APIs.

Cannot use property expression in class mediator in WSO2 ESB 4.9.0

I created a class mediator and need to use expression for password property because it has been encrypted in vault,
However, the property inside of class mediator () seems not support expression. There is an exception in console,
We ran into same issue. We were unable use expression on a property for the class Mediator.
I am by no means an expert so if there is a better way hopefully someone else will speak up but this is how I got it working.
Change the property on your inSequence to this, really only adding scope="default"
<property name="passwordvault"
expression="wso2:vault-lookup('proxy.sunb.password')"
scope="default"/>
Then once you set that you can retrieve it inside nz.govt.mpi.NtlmAuthorisation2 retrieve the value like this
password = (String) synMgtx.getProperty("passwordvault");

How To Know The Client Url in Wso2ESB sing property Mediator

i have two proxys . i wish to filter the Client url in second proxy means
my first proxy implemented and send some data to 2nd proxy.Its working fine But my wish i dont want allow any other service to use my proxy .In that case i need to filter based On the URL. We have option in ESb get-property('To') for know to url of target service but How we can know that Which client is calling me
`<property name="client-host" expression="get-property('From')"/>`
this property not working
even i defined in Client and target service also but its returning "null"
<property name="client-host" expression="get-property('To')"/>
this property returning me present service URl
But i need Client Url Who is calling me...
how could i define it and where can i define either in Client Or Target
http://docs.wso2.org/wiki/display/ESB460/Property+Mediator#PropertyMediator-PropertiesToFromActionFaultToReplyToMessageID
can you enable the ws-addressing module to your proxies and see that "from" property is working or not?
Generally from,to action properties are captured from transport receiver..
WS-addressing will capture same properties and if they are already available, ws-addressing will overwrite them...