WSO2 ESB: Get Address Endpoint URI from registry - wso2

I want to define my URL in the registry so that I can change it between environments without having to redeploy CAR files. I have done this successfully in the past for HTTP Endpoints, but with Address Endpoints, I cannot get it to work.
How I normally would do it, is to declare the property in the API.xml file:
<property name="uri.var.my_EP" expression="get-property('registry', 'gov:/integration/endpoints/myapp/my_EP')" scope="default" type="STRING"/>
Then I simply replace the hard-coded URI with my property in the endpoint.xml file:
<http method="post" uri-template="{uri.var.my_EP}">
If I do the following on the Address Endpoint, I get a "The system cannot infer the transport information from the {uri.var.my_EP}" error:
<address uri="{uri.var.my_EP}">
What/how must I do to define the URI for Address Endpoints in the registry?

If you have properly stored in registry, you can use endpoint directly like below:
<endpoint key="gov:/integration/endpoints/myapp/my_EP"/>
Personally, for endpoints i use conf:/.. repository.

Related

WSO2 - cookie on second call in Service Proxy

I need to make proxy service in wso2 esb, that would be redirect requests to external wsdl service with pre send auth request to separate operation.
I make sequence like this:
clone
payloadFactory (auth xml request)
call (auth operation)
property (value=get-property('transport', 'Set-Cookie'), name=ExtCookie scope=operation)
property (value=get-property('operation', 'ExtCookie') name=Cookie)
Send (target operation)
When I make first call to this proxy service - It's work fine. But on second call I see in tcpdump that there is Cookie HTTP Header in the clone request.
I try add "property remove" with different scope(transport, operation, Synapse, default, axis2, axis2-client), but no one work. Cookie-Header wasn't removed. I need remove it for correct work with ext service.
Try with the following properties.
<property name="EXCESS_TRANSPORT_HEADERS" scope="axis2" action="remove"/>
<property name="Set-Cookie" scope="transport" action="remove"/>

How to add a URL parameter using a WSO2 Mediation Flow?

I have successfully deployed a WSO2 API Manager. I am already using mediation flows for setting Header information, but now I am adding an API that requires a key to be set as an URL parameter. However I would like this to be added in the background so that the end-users don't have to worry about this key.
How can this be done in a Message Mediation Policy/Flow? Obviously the other parameters that are already present should stay untouched.
Thanks in advance
Hope you can access the key inside the synapse context. Then you can assign the key value to the uri.var object as below.
<property name="uri.var.key" expression="get-property('userParames.key')"/>
Now you can simply construct the endpoint as,
<endpoint>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/abc/{uri.var.key}"/>
</endpoint>

WSO2 Developing Custom Endpoint

i need to extend the LoadBalance Endpoint developing my custom endpoint.
I tried:
1)
public class CustomLoadBalanceEndpoint extends LoadbalanceEndpoint
2) i exported it using wso2 studio in the /repository/components/dropins folder
3) i cannot find the way to use it inside ESB... I tried with this code
<endpoint class="it.innovapuglia.sistemapuglia.wso2.enpoint.CustomLoadBalanceEndpoint"
algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
<endpoint name="tomcat1">
<address uri="http://localhost:8080/RestService/rest/servizio"/>
</endpoint>
</endpoint>
but ESB doesn't accept it saying me "Proxy service requires a valid in sequence or a valid endpoint."
You can not use your endpoint like that.
After developing your custom endpoint keep that in the repository/components/lib folder.You have to call your endpoint like this;
<endpoint name="CustomEndpoint">
<class name="org.wso2.carbon.endpoint.CustomLoadBalanceEndpoint">
</class>
</endpoint>
Check the following posts on how to add your custom endpoint concepts.
[1]http://vvratha.blogspot.com/2012/07/class-endpoints-in-synapse.html
[2]http://vvratha.blogspot.com/2013/06/class-endpointssample.html

WSO2 indirect Endpoint inside Failover Group

Is it possible to use an Indirect Enpoint inside the definition of a Failover Group endpoint?
I mean something like this:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="failOver2">
<failover>
<endpoint key="LBEndpoint" />
</failover>
</endpoint>
Where LBEndpoint is a load balance endpoint defined and saved previously in the registry.
When i click on the Save button... all my configuration is lost and the fail over group comes back into this form:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="failOver2">
<failover/>
</endpoint>
Is this a bug? Inside the WSO2 ESB documentation it says that all this is possible.
Can you try editing synapse configuration directly? That is, not using sequence editor UI. Go to sourceview and manually edit and point the endpoint key in failoverendpoint.

How to access system property from WSO2 ESB and Registry

My WSO2 ESB proxy service references an endpoint which is located at different URLs in various environments - DEV, TEST, PROD. According to the WSO2 documentation, I need to store the endpoint definition in the Governance Registry and modify the URL in endpoint XML file in each environment. That might work fine for the organizations with 1 or 2 proxies, but becomes a significant overhead for a 10+ proxies.
Another scenario is when I need to read certain environment-specific properties in my ESB sequence.
Is there a way to define a bunch of properties in the external *.properties file and then read them within the ESB and Registry definitions?
You can access system properties inside ESB sequences/proxy services using the script mediator as follows;
<script language="js">mc.setProperty("file.separator",java.lang.System.getProperty("file.separator"));</script>
<log level="custom">
<property name="file.separator" expression="get-property('file.separator')"/>
</log>
Here "file.separator" property is set as the property in the message context inside the script mediator and it can be used in subsequent mediators.
You also can access properties defined in a file in ESB registry. For example if you have a file in configuration registry (test.xml) with the following content,
<a>Helloo<b>World</b></a>
The text element "World" in <b> can be accessed using property mediator as follows,
<property name="test" expression="get-property('registry','conf:/test.xml')" scope="default" type="OM"/>
<log level="custom">
<property name="test.b" expression="$ctx:test//b"/>
</log>
here is a blog post on how to access registry resources from a classmeditor1. You can access any resources as mentioned in the post and do modifications.
Likewise you can keep the external properties file and read that from the classmeditor and set all properties in synapse message context using class meditaor.