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.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
Continuity8
  • 2,403
  • 4
  • 19
  • 34
  • what do you mean by " some sort of URL lookup, based on environment." here? – lakshman Jan 18 '16 at 06:23
  • 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. – Continuity8 Jan 18 '16 at 06:25
  • How about storing it in conf location as a xml? Will you Ok with it and read from there? – harsha89 Jan 22 '16 at 08:46

1 Answers1

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.

Amila Maharachchi
  • 2,121
  • 2
  • 15
  • 21