Jaggery (WS02) endpoint reference/dynamic endpoint
Asked Answered
M

1

7

I'm currently developing an application in Jaggery which I deploy on their API manager.

From the Jaggery back end I'm calling a SOAP webservice using the method documented here, which specifies:

<%      
var url = 'http://jaggeryjs.org/apidocs/resources/home.jag'; 
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("user" , "madhuka");
xhr.send();

print("ReadyState : "+xhr.readyState);
print("<br>ResponseStatus : "+xhr.status);
print("<br>ResponseText : "+xhr.responseText);
%>

I have everything up and working fine, however I'd like to remove the hard-coded URL and replace it with some sort of URL lookup, based on environment.

What is the correct way of doing this? Can I specify an endpoint in API manager and refer to it? Or perhaps use an EPR file. I've had little luck with the Jaggery documentation in this sense.

Molybdous answered 18/1, 2016 at 2:39 Comment(3)
what do you mean by " some sort of URL lookup, based on environment." here?Cake
The service endpoint will be different for different environments, i.e. if it's deployed to Dev or SIT. Wherever it is deployed to it must find the right endpoint.Molybdous
How about storing it in conf location as a xml? Will you Ok with it and read from there?Shin
V
1

I have seen many jaggery apps developed for WSO2 products. The practice followed in them is to have a config file in json format. You can have a method to read it and get necessary values by passing the attribute name.

You can either have a config file for each environment and pack the correct one with the app or have a single config file with endpoints for each environment. If you are going to maintain a single config file, you have to dynamically construct the attribute name and read its value. To do that also, you need to maintain which environment it is. Therefore I recommend to use a config file for each environment and bundle the correct file for the environment.

Vermont answered 21/4, 2016 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.