WSO2 Developing Custom Endpoint - wso2

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

Related

WSO2 ESB: Get Address Endpoint URI from registry

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.

What exactly does this WSO2 ESB echo endpoint?

I am very new in WSO2 and I have the following doubt related to an ESB project on which I am working.
In this ESB application I am sending a message to a named endopoint mediator, something like this:
<send>
<endpoint key="echoEndpoint"/>
</send>
This is the contend of the related echoEndpoint.xml file in my project:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="echoEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<address format="soap11" statistics="enable" trace="enable" uri="http://localhost:8280/services/echo"/>
</endpoint>
So what exactly does this endpoint? The http://localhost:8280/services/echo is something like a predefined endopoined provided natively by WSO2? or what?
echo service included into esb/ei by default. You can see it in Carbon Panel -> Main -> Manage -> Services. There you can test it via "Try It" feature. It has few methods:
echoInt extected to get integer as argument and returned same integer value
echoString - expected to get string value as argument and returned same value
echoOMElement - received XML as argument and returned same XML
and some other methods. General idea - this service returned same value as it is received.
This service is helpful for testing purposes.
This is a service that by default is already displayed when you run the ESB. Echo.aar is located in the path repository\deployment\server\axis2services . And wsdl you can see https://localhost:your_Port/services/echo?wsdl

How do I pass a dynamic parameter as a part of the URL of a REST service while using WSO2 ESB Proxy Service?

I am trying to simply host a REST service as a proxy service in WSO2 ESB. I am using Custom Proxy to do this. When I run the created proxy, I am not able to pass parameters to the proxy service at run time. How do I do this?
My REST service will be hit on a URL of format:http://ip:host/requestMapping/{name}
The parameter 'name' has to be passed from the UI through the ESB to the service through a proxy service hosted on the ESB. Can you help me with the steps to follow to make this work?
I tried using this page:
http://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/
But that is for creating APIs which I have been successfully in creating. But I am unable to do this using Proxy services.
Basically in my program, when the user interacts with the UI, he enters a name as input. This name has to be passed to the proxy service hosted in the ESB which should forward this as a path variable to my REST service.
Right now, my service body is:
<inSequence>
<send>
<endpoint>
<http method="POST" uri-template="http://ip:port/resourceMapping/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
When I run this, instead of sending the name as entered by the user, it sends "uri.var.name" to the REST service. On the other hand, if I define a property tag and define a value for it and then do this, the REST service gets the value of the property that I have set. But I need this value to be sent dynamically by the user so I can't define property and value inside.
Please help me.
I think, the best approach is to use API in this case because the request to the ESB is REST and endpoint also accepting REST. This is the best practice.

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.

WSO2 ESB send to multiple endpoints

Can a message be sent to multiple endpoints from within the send mediator in a proxy service?
This link from the WSO2 ESB Send Mediator documentation says under the Syntax chapter that If the message is to be sent to one or more endpoints, then the following is used:
<send>
(endpointref | endpoint)+
</send>
where the endpointref token refers to the following:
<endpoint key="name"/>
I've tried to include two endpoints under send, but the second one gets removed automatically when saving the proxy service (inside the Developer Studio or straight in the ESB Stratos interface). I did go to the Synapse page for the Send Mediator to see if they say anything special and their format says:
(endpointref | endpoint)?
Now assuming these characters represent regular expression, ? stands for 0 or 1 times, + is 1 or more times. Did WSO2 implement this extra "one or more endpoints" feature on top of Synapse Send Mediator or is it just a mistake on the documentation pages. If they did, what's the exact syntax to make it work?
Thank you!
Actually you can use Recipienlist endpoint to send a single message to multiple endpoints.
After defining recipient list store taht as localentry and provide that as endpoint key.
You can do something like this:
<send>
<endpoint key="jmsMBendpoint1"/>
</send>
<send>
<endpoint key="jmsMBendpoint2"/>
</send>
.I have used this approach and is working for me.
You can use the clone mediator to send to multiple endpoints with specifying respective endpoints as in the below configuration.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="send_to_all">
<clone sequential="false">
<target endpoint="endpoint1"/>
<target endpoint="endpoint2"/>
<target endpoint="endpoint3"/>
</clone>
<drop/>
</sequence>