Dynamically obtain server/domain name on SWON service

17 views
Skip to first unread message

William Ramos

unread,
Oct 23, 2019, 6:06:08 PM10/23/19
to TopBraid Suite Users
Hi, community;

I have a SWON service where I'm generating a value as a URL which should be based on the server where the SWON service is running.

The company where I work has three different servers/domains:

So, for example if I'm running the SWON service on test.company.com it should generate the URL like this:
url:"https://test.company.com?someService;graphURI..."
... if running the service on dev.company.com it should look generate it like this:
url:"https://dev.company.com?someService;graphURI..."

The SWON code that I have looks like this:
<swon:Value arg:name="url" arg:value="https://test.company.com?someService;graphURI={= ?guri }"/>
...with the domain/server hardcoded, so I'm wondering if there's a built in function/mechanism to achieve this.

Thanks in advance.

Holger Knublauch

unread,
Oct 23, 2019, 7:30:16 PM10/23/19
to topbrai...@googlegroups.com

Hi William,

one thing to try would be the server URL config parameter (admin page):

You can query that value using smf:configParam("serverURL").

Alternatively, if changing this value has undesired side effects, you could probably make up another triple somewhere, e.g. by uploading a TTL file to each server.

HTH
Holger

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/b73bfb67-7903-434d-a5a5-a795d5473b91%40googlegroups.com.

Richard Cyganiak

unread,
Oct 27, 2019, 7:43:13 AM10/27/19
to topbraid-users list
Hi William,

As Holger said, the best way to handle this is by setting the serverURL in the configuration.

Besides using smf:configParam to read the value of the setting, it can also be done using ui:createLink. That is a control element that creates an URL and assigns it to the variable ?link for further use. Its ui:absolute attribute must be set to true to get an absolute URL including the server base URL. For example:

<ui:createLink ui:absolute="true" ui:viewClass="ex:someService" arg:graphURI="{= ?guri }">
<swon:Value arg:name="url" arg:value="{= ?link }"/>
</ui:createLink>

This might assign the following value to the variable ?link:

http://localhost:8083/tbl/swp?_viewClass=ex:someService&graphURI=urn:x-evn-master:test

Another example that calls the GraphQL service instead of an SWP service:

<ui:createLink ui:absolute="true" ui:servlet="graphql/{= ?graphId }" arg:query="{= ?graphqlQuery }">
...
</ui:createLink>

This would set ?link to something like:

http://localhost:8083/tbl/graphql/test?query=...

See https://uispin.org/ui.html#createLink for more information.

Richard
Reply all
Reply to author
Forward
0 new messages