WSO2Con 2013 CFP Banner

How to customize the service URL using Tungsten

Discuss this article on Stack Overflow
By Saminda Abeyruwan
  • 9 Jun, 2006
  • Level: 
  • Reads: 3200

Q. The default Tungsten service URL is /axis2/services/Foo. How do I customize this?

Saminda Abeyruwan

WSO2 Inc.

A. Tungsten users can easily change the service url via tungsten.xml. The default values are set as follows,

    <!-- ************************************************* -->
<!-- Setting for ServiceURL -->
<!-- ************************************************* -->
<ServiceURL>
<ContextPath>axis2</ContextPath>
<ServicePath>services</ServicePath>
</ServiceURL>
Therefore, if a user wants their urls to be unique in either standalone or embeddable instances, all they have do is to change <ContextPaht/> and <ServicePath/> in <ServiceURL/> element. Say, you want to archive the following service url as /MyProject/MyServices/. Then the user has to do the following:
    <!-- ************************************************* -->
<!-- Setting for ServiceURL -->
<!-- ************************************************* -->
<ServiceURL>
<ContextPath>MyProject</ContextPath>
<ServicePath>MyServices</ServicePath>
</ServiceURL>

In the above case, the service url Tungsten will support is https:MyHost:MyPort/MyProject/MyServices/Foo. Once you've customized your service url, to get the AJAX based Tungsten Administration working, user has to tweak the “main.js” of the distribution, which is found in lib/www/js folder in the standalone distribution or in the extracted war in the case of the embeddable distribution.

In the top part of the “main.js” user will be able to see the following lines of code.

/*
//////// CAUTION /////////////////
//////// Change the values, if change the following entries in Tungsten.xml //////////

****************************************
Setting for ServiceURL
****************************************
<ServiceURL>
<ContextPath>axis2</ContextPath>
<ServicePath>services</ServicePath>
</ServiceURL>

*/
var CONTEXT_PATH_DEFAULT = "axis2";
var SERVICE_PATH_DEFAULT = "services";

var contextPath = CONTEXT_PATH_DEFAULT;
var servicePath = SERVICE_PATH_DEFAULT;

var serviceURL = "/" + contextPath + "/" + servicePath;

As you can see “contextPath” variable and “servicePath” variable is set to its default values. So, just replace them with your custom values as seen below.
var contextPath = “MyProject”;
var servicePath = “MyServices”;

Now, your AJAX client will sync with the Tungsten instance you are using. Note: The above features are available in current svn codebase, and not in Tungsten 1.0 release.

Applies To:

WSO2 WSAS (previously known as Tungsten) for Java, v 1.1 and above

 

WSO2Con 2014 USA