Calling WSO2-ESB Admin Services using Jaggery App

Introduction

WSO2 ESB (Enterprise Service Bus) has shown good performance compared to other Open-Source ESBs. WSO2 ESB contains a Management Console to configure settings and run-time Synapse instance which does all kinds of message meditations. In that context, Admin Services play the middle-man role, with abstraction. Which means it helps Management UI to interact with run-time Synapse instance in a convenient way (with SOAP messages).

On the other hand Jaggery is written by WSO2 to make server-side coding easy for JavaScript lovers. Coders can perform many things with Jaggery using the same syntax as JS using. That eliminates the necessity of learning another server-side language.

What’s going to happen

During a project, i wanted to access the TaskAdmin admin service using a Jaggery app. For this case I believe reader has fundamental knowledge about WSO2 ESB and Jaggery. Then using the following code you can access the TaskAdmin service and add a new Scheduled Task to WSO2 ESB .


// Open task xml file
var path = "task.xml";
var file = new File(path);

// Here open file just to read
file.open("r");

// Read task xml file and convert to xml object
var taskFile = file.readAll();
var taskFileXml = new XML(taskFile);

// Sending a request to Task-Admin service containing task.xml
var ws = require("ws");

var req = new ws.WSRequest();
var options = new Array();

options.useSOAP = 1.2;

// Method for adding task through admin service
options.action = "urn:addTaskDescription";

var result;

try {
// Open connection to Task Admin service - url currently hardcoded
req.open(options,"https://localhost:9445/services/TaskAdmin", false, "admin", "admin"); // URI with offset=2 in ESB//

// Send task.xml
req.send('<ns1:addTaskDescription xmlns:ns1="http://org.apache.axis2/xsd">' + taskFileXml + '</ns1:addTaskDescription>');

} catch (e) {

// print(e.toString()); //If returns an error

}

file.close();


Sample task.xml file can be as follows:


<task xmlns="http://www.wso2.org/products/wso2commons/tasks" class="org.wso2.carbon.recipeexecutor.RecipeMessageExecutor" group="synapse.simple.quartz" name="RecipeTask2">
<trigger count="1" interval="100"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="recipeParams">
<salesforceGooglespreadsheet.syncContacts xmlns="">
<salesforce.username></salesforce.username>
<salesforce.password></salesforce.password>
<salesforce.batchSize></salesforce.batchSize>
<googlespreadsheet.username></googlespreadsheet.username>
<googlespreadsheet.password></googlespreadsheet.password>
<googlespreadsheet.spreadsheetName></googlespreadsheet.spreadsheetName>
<googlespreadsheet.worksheetName></googlespreadsheet.worksheetName>
<googlespreadsheet.batchEnable></googlespreadsheet.batchEnable>
<googlespreadsheet.batchSize></googlespreadsheet.batchSize>
</salesforceGooglespreadsheet.syncContacts>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="regKey" value="gov:/recipes/sf_gss_template"/>
</task>


Other admin services available in WSO2 ESB (in version 4.8.1).

Note that ports of the following list has offset of 2 than default.

1. ProvisioningAdminService, ProvisioningAdminService, https://buddhima-pc:8245/services/ProvisioningAdminService
2. SynapseApplicationAdmin, SynapseApplicationAdmin, https://buddhima-pc:8245/services/SynapseApplicationAdmin
3. MediationSecurityAdminService, MediationSecurityAdminService, https://buddhima-pc:8245/services/MediationSecurityAdminService
4. CarbonAppUploader, CarbonAppUploader, https://buddhima-pc:8245/services/CarbonAppUploader
5. OperationAdmin, OperationAdmin, https://buddhima-pc:8245/services/OperationAdmin
6. SequenceAdminService, SequenceAdminService, https://buddhima-pc:8245/services/SequenceAdminService
7. MediationLibraryAdminService, MediationLibraryAdminService, https://buddhima-pc:8245/services/MediationLibraryAdminService
8. StatisticsAdmin, StatisticsAdmin, https://buddhima-pc:8245/services/StatisticsAdmin
9. LoggedUserInfoAdmin, LoggedUserInfoAdmin, https://buddhima-pc:8245/services/LoggedUserInfoAdmin
10. MediationStatisticsAdmin, MediationStatisticsAdmin, https://buddhima-pc:8245/services/MediationStatisticsAdmin
11. TopicManagerAdminService, TopicManagerAdminService, https://buddhima-pc:8245/services/TopicManagerAdminService
12. MessageProcessorAdminService, MessageProcessorAdminService, https://buddhima-pc:8245/services/MessageProcessorAdminService
13. ApplicationAdmin, ApplicationAdmin, https://buddhima-pc:8245/services/ApplicationAdmin
14. NDataSourceAdmin, NDataSourceAdmin, https://buddhima-pc:8245/services/NDataSourceAdmin
15. ServiceGroupAdmin, ServiceGroupAdmin, https://buddhima-pc:8245/services/ServiceGroupAdmin
16. ClassMediatorAdmin, ClassMediatorAdmin, https://buddhima-pc:8245/services/ClassMediatorAdmin
17. CustomMeteringService, CustomMeteringService, https://buddhima-pc:8245/services/CustomMeteringService
18. BAMMediatorConfigAdmin, BAMMediatorConfigAdmin, https://buddhima-pc:8245/services/BAMMediatorConfigAdmin
19. STSAdminService, STSAdminService, https://buddhima-pc:8245/services/STSAdminService
20. RegistryAdminService, RegistryAdminService, https://buddhima-pc:8245/services/RegistryAdminService
21. FileDownloadService, FileDownloadService, https://buddhima-pc:8245/services/FileDownloadService
22. CachingAdminService, CachingAdminService, https://buddhima-pc:8245/services/CachingAdminService
23. MessageStoreAdminService, MessageStoreAdminService, https://buddhima-pc:8245/services/MessageStoreAdminService
24. RMAdminGlobal, RMAdminGlobal, https://buddhima-pc:8245/services/RMAdminGlobal
25. LoginStatisticsAdmin, LoginStatisticsAdmin, https://buddhima-pc:8245/services/LoginStatisticsAdmin
26. CustomUIAdminService, CustomUIAdminService, https://buddhima-pc:8245/services/CustomUIAdminService
27. ReportingResourcesSupplier, ReportingResourcesSupplier, https://buddhima-pc:8245/services/ReportingResourcesSupplier
28. RMAdminService, RMAdminService, https://buddhima-pc:8245/services/RMAdminService
29. SearchAdminService, SearchAdminService, https://buddhima-pc:8245/services/SearchAdminService
30. JMSTransportAdmin, JMSTransportAdmin, https://buddhima-pc:8245/services/JMSTransportAdmin
31. ThrottleAdminService, ThrottleAdminService, https://buddhima-pc:8245/services/ThrottleAdminService
32. TaskAdmin, TaskAdmin, https://buddhima-pc:8245/services/TaskAdmin
33. ModuleAdminService, ModuleAdminService, https://buddhima-pc:8245/services/ModuleAdminService
34. MediationTracerService, MediationTracerService, https://buddhima-pc:8245/services/MediationTracerService
35. RestApiAdmin, RestApiAdmin, https://buddhima-pc:8245/services/RestApiAdmin
36. LoggingAdmin, LoggingAdmin, https://buddhima-pc:8245/services/LoggingAdmin
37. ExternalTryitService, ExternalTryitService, https://buddhima-pc:8245/services/ExternalTryitService
38. SecurityAdminService, SecurityAdminService, https://buddhima-pc:8245/services/SecurityAdminService
39. KeyStoreAdminService, KeyStoreAdminService, https://buddhima-pc:8245/services/KeyStoreAdminService
40. JrxmlFileUploader, JrxmlFileUploader, https://buddhima-pc:8245/services/JrxmlFileUploader
41. DiscoveryAdmin, DiscoveryAdmin, https://buddhima-pc:8245/services/DiscoveryAdmin
42. EndpointAdmin, EndpointAdmin, https://buddhima-pc:8245/services/EndpointAdmin
43. ServerRolesManager, ServerRolesManager, https://buddhima-pc:8245/services/ServerRolesManager
44. ResourceAdminService, ResourceAdminService, https://buddhima-pc:8245/services/ResourceAdminService
45. ThemeMgtService, ThemeMgtService, https://buddhima-pc:8245/services/ThemeMgtService
46. FileUploadService, FileUploadService, https://buddhima-pc:8245/services/FileUploadService
47. DataSourceAdmin, DataSourceAdmin, https://buddhima-pc:8245/services/DataSourceAdmin
48. MediationLibraryUploader, MediationLibraryUploader, https://buddhima-pc:8245/services/MediationLibraryUploader
49. WSDLValidatorService, WSDLValidatorService, https://buddhima-pc:8245/services/WSDLValidatorService
50. ConfigServiceAdmin, ConfigServiceAdmin, https://buddhima-pc:8245/services/ConfigServiceAdmin
51. CommandMediatorAdmin, CommandMediatorAdmin, https://buddhima-pc:8245/services/CommandMediatorAdmin
52. EventBrokerService, EventBrokerService, https://buddhima-pc:8245/services/EventBrokerService
53. TracerAdmin, TracerAdmin, https://buddhima-pc:8245/services/TracerAdmin
54. TransportAdmin, TransportAdmin, https://buddhima-pc:8245/services/TransportAdmin
55. MultipleCredentialsUserAdmin, MultipleCredentialsUserAdmin, https://buddhima-pc:8245/services/MultipleCredentialsUserAdmin
56. ProxyServiceAdmin, ProxyServiceAdmin, https://buddhima-pc:8245/services/ProxyServiceAdmin
57. Java2WSDLService, Java2WSDLService, https://buddhima-pc:8245/services/Java2WSDLService
58. UserStoreConfigAdminService, UserStoreConfigAdminService, https://buddhima-pc:8245/services/UserStoreConfigAdminService
59. InfoAdminService, InfoAdminService, https://buddhima-pc:8245/services/InfoAdminService
60. RepositoryAdminService, RepositoryAdminService, https://buddhima-pc:8245/services/RepositoryAdminService
61. PriorityMediationAdmin, PriorityMediationAdmin, https://buddhima-pc:8245/services/PriorityMediationAdmin
62. TenantMgtAdminService, TenantMgtAdminService, https://buddhima-pc:8245/services/TenantMgtAdminService
63. DeploymentSynchronizerAdmin, DeploymentSynchronizerAdmin, https://buddhima-pc:8245/services/DeploymentSynchronizerAdmin
64. TemplateAdminService, TemplateAdminService, https://buddhima-pc:8245/services/TemplateAdminService
65. RelationAdminService, RelationAdminService, https://buddhima-pc:8245/services/RelationAdminService
66. DBReportingService, DBReportingService, https://buddhima-pc:8245/services/DBReportingService
67. ServerAdmin, ServerAdmin, https://buddhima-pc:8245/services/ServerAdmin
68. ServiceAdmin, ServiceAdmin, https://buddhima-pc:8245/services/ServiceAdmin
69. FlowsAdminService, FlowsAdminService, https://buddhima-pc:8245/services/FlowsAdminService
70. UserAdmin, UserAdmin, https://buddhima-pc:8245/services/UserAdmin
71. PropertiesAdminService, PropertiesAdminService, https://buddhima-pc:8245/services/PropertiesAdminService
72. LogViewer, LogViewer, https://buddhima-pc:8245/services/LogViewer
73. WSDL2CodeService, WSDL2CodeService, https://buddhima-pc:8245/services/WSDL2CodeService
74. SynapseArtifactUploaderAdmin, SynapseArtifactUploaderAdmin, https://buddhima-pc:8245/services/SynapseArtifactUploaderAdmin
75. LocalEntryAdmin, LocalEntryAdmin, https://buddhima-pc:8245/services/LocalEntryAdmin
76. EndpointTemplateAdminService, EndpointTemplateAdminService, https://buddhima-pc:8245/services/EndpointTemplateAdminService

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s