BuiltInService to find Hostname/DNS name

I have written a service getEnvironment which simply set’s the server environment type… The service contains a single map element… In the pipeline out I set a variable envType to “prod” in the production environment… Similarly “test” in TEST environment… The trouble is my team want’s me to change this service and set this variable by finding out the DNS name(Server Environment) at runtime instead of the hardcoding… I did not find any built-in service which returns the hostname/DNS name… Please let me know if there exists a service which return me these values or how should I implement this idea…

Regards,
Prashanth

hi prashanth,
u can find the built in services in WmSamples package for server information(getServerInformation) and also in PS_Utilities package which u can find in webmethods advantage,
HTH
sri

Sri’s suggestion will work, but I think a better approach is to use a properties file. Or for a property like this, add a new propertyy to the IS Extended Settings list with a name/value pair like “watt.server.enviroment.name=PROD”. That way you can edit that setting from within Administrator and it is not affected by package deployments.

HTH,

Mark

Hi…

I wrote the following java service to fetch the DNS name…

try {
IDataCursor idc = pipeline.getCursor();
InetAddress address = InetAddress.getLocalHost();
String HostName = address.getHostName();
String HostIPAddress = address.getHostAddress();
idc.insertAfter(“HostName”, HostName);
idc.insertAfter(“HostIPAddress”, HostIPAddress);
idc.destroy();
} catch (UnknownHostException e) { System.err.println("Unable to lookup "); }

Mark how can I read the value set for watt.server.environment.name=PROD in the Administrator…?

You can do this with:
wm.server.query:getExtendedSettings
or
wm.server.query:getExtendedSettingsVisible,

those are not visible in Developer but you can invoked them, or from java, or just insert some invoke step and then change the “Service” param in Properties panel.

If you want to get the value of a single property from IS system properties you can use the following java service:

[highlight=java]
IDataCursor idc = pipeline.getCursor();
String propertyKey = null;
String propertyValue = null;

//get the propertyKey to be retrieved from the pipeline
if (idc.first(“propertyKey”)) propertyKey = (String) idc.getValue();

if (propertyKey==null) {
throw new ServiceException(“Parameter “propertyKey” must not be null or empty”);
}

//use System.getProperty to retrieve propertyValue from System properties
propertyValue = System.getProperty(propertyKey);

//delete existing propertyValue in pipeline if present
if (idc.first(“propertyValue”)) idc.delete();

//insert retrived propertyValue into pipeline
idc.insertAfter(“propertyValue”, propertyValue);

idc.destroy();
[/highlight]