Skip to content

Instantly share code, notes, and snippets.

@uphy
Created February 10, 2017 06:16
Show Gist options
  • Save uphy/61ee26f2b12d27f679785c42839bc650 to your computer and use it in GitHub Desktop.
Save uphy/61ee26f2b12d27f679785c42839bc650 to your computer and use it in GitHub Desktop.
import org.apache.commons.httpclient.Header;
import org.wso2.carbon.endpoint.stub.types.EndpointAdminEndpointAdminException;
import org.wso2.carbon.registry.info.stub.RegistryExceptionException;
import org.wso2.carbon.registry.resource.stub.ResourceAdminServiceExceptionException;
import org.wso2.carbon.registry.resource.stub.ResourceAdminServiceStub;
import org.wso2.carbon.rest.api.stub.RestApiAdminAPIException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
public class ResourceAdminServiceClientSample2 {
public static void main(String[] args) throws RemoteException, RestApiAdminAPIException, EndpointAdminEndpointAdminException, RegistryExceptionException, ResourceAdminServiceExceptionException {
System.setProperty("javax.net.ssl.trustStore", "/Users/ishikura/wso2am/wso2am-2.1.0/repository/resources/security/wso2carbon.jks");
final String backendUrl = "https://localhost:9443/services/";
final String userName = "admin";
final String password = "admin";
final String path = "/_system/governance/apimgt/applicationdata/workflow-extensions.xml";
final ResourceAdminServiceStub resourceAdminServiceStub = new ResourceAdminServiceStub(backendUrl + "ResourceAdminService");
final List<Header> headers = new ArrayList<>();
headers.add(new Header("Authorization", "Basic " + Base64.getEncoder().encodeToString(String.format("%s:%s", userName, password).getBytes())));
resourceAdminServiceStub._getServiceClient().getOptions().setProperty("HTTP_HEADERS", headers);
String workflowExtensions = resourceAdminServiceStub.getTextContent(path);
System.out.println(workflowExtensions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment