Over a million developers have joined DZone.
Platinum Partner

Create a Proxy in WSO2 ESB Using Admin Services

· Integration Zone

The Integration Zone is brought to you in partnership with 3scale. Discover why Rails + jspm >= ECMAScript 6 awesomeness.

Do you want to know how to create a proxy in WSO2 ESB without using UI? Here is some sample code that will help you understand how to use an admin service to achieve the task:

package org.wso2.test;
import org.apache.axis2.AxisFault;
import org.wso2.carbon.proxyadmin.stub.ProxyServiceAdminProxyAdminException;
import org.wso2.carbon.proxyadmin.stub.ProxyServiceAdminStub;
import org.wso2.carbon.proxyadmin.stub.types.carbon.ProxyData;
import org.wso2.carbon.utils.CarbonUtils;
import java.rmi.RemoteException;
public class TestProxy {
    public static void main(String[] args)
            throws RemoteException, ProxyServiceAdminProxyAdminException {
        String userName = "admin";
        String password = "admin";
        // Add the service URL
        String serviceEndPoint="http://localhost:8281/services/echo" ;
        // Proxy Admin service's endpoing URL
        String endPoint = "https://localhost:9444/services/" +"ProxyServiceAdmin";
        // Set client trust store
        System.setProperty("javax.net.ssl.trustStore", "/media/data/wso2/products/wso2/esb/" +
                                                       "wso2esb-4.5.0/repository/resources/security" +
        System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
        ProxyServiceAdminStub proxyServiceAdminStub = new ProxyServiceAdminStub(endPoint);
        CarbonUtils.setBasicAccessSecurityHeaders(userName, password,
        //Set proxy configuration data
        String[] transport = {"http", "https"};
        ProxyData data = new ProxyData();
        data.setEndpointXML("<endpoint http:="http:" ns="ns" synapse="synapse" ws.apache.org="ws.apache.org" xmlns="\"><address serviceendpoint="serviceendpoint" uri="\">

You can download the complete maven project here.


The Integration Zone is brought to you in partnership with 3scale. Learn how to deploy an NGINX API gateway on Heroku.


Published at DZone with permission of Shelan Perera , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}